login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

How to have an output similar to a 1D input form?

fricas
)set output tex off
---disable tex display (if needed)
fricas
)set output algebra on
---enable 2D display
res:=expand((1+x)^10) --- large result
(1) 10 9 8 7 6 5 4 3 2 x + 10 x + 45 x + 120 x + 210 x + 252 x + 210 x + 120 x + 45 x + 10 x + 1
Type: Polynomial(Integer)
fricas
matrix( [[res,res],[res,res]])   --- even larger
(2) [ [ 10 9 8 7 6 5 4 3 x + 10 x + 45 x + 120 x + 210 x + 252 x + 210 x + 120 x + 2 45 x + 10 x + 1 ,
10 9 8 7 6 5 4 3 x + 10 x + 45 x + 120 x + 210 x + 252 x + 210 x + 120 x + 2 45 x + 10 x + 1 ] ,
[ 10 9 8 7 6 5 4 3 x + 10 x + 45 x + 120 x + 210 x + 252 x + 210 x + 120 x + 2 45 x + 10 x + 1 ,
10 9 8 7 6 5 4 3 x + 10 x + 45 x + 120 x + 210 x + 252 x + 210 x + 120 x + 2 45 x + 10 x + 1 ] ]
Type: Matrix(Polynomial(Integer))
fricas
--- 1D output soon...
res::InputForm --- force input form ?Is this lisp?
(3) (+
(+
(+
(+
(+
(+
(+
(+ (+ (+ (^ x 10) (* 10 (^ x 9))) (* 45 (^ x 8))) (* 120 (^ x 7)))
(* 210 (^ x 6)))
(* 252 (^ x 5)))
(* 210 (^ x 4)))
(* 120 (^ x 3)))
(* 45 (^ x 2)))
(* 10 x))
1)
Type: InputForm
fricas
unparse(res::InputForm)      --- what we want
(4) "x^10+10*x^9+45*x^8+120*x^7+210*x^6+252*x^5+210*x^4+120*x^3+45*x^2+10*x+1"
Type: String
fricas
--- this is a one character one parameter macro that implements the idea:
% r ==> unparse(r::InputForm)
Type: Void
fricas
% res
(6) "x^10+10*x^9+45*x^8+120*x^7+210*x^6+252*x^5+210*x^4+120*x^3+45*x^2+10*x+1"
Type: String
fricas
--- this is a 2 characters one parameter macro that implements alternative way but equivalent result:
%%  r ==> unparse convert r
Type: Void
fricas
%% res
(8) "x^10+10*x^9+45*x^8+120*x^7+210*x^6+252*x^5+210*x^4+120*x^3+45*x^2+10*x+1"
Type: String
fricas
% matrix( [[res,res],[res,res]])
(9) "matrix([[x^10+10*x^9+45*x^8+120*x^7+210*x^6+252*x^5+210*x^4+120*x^3+45*x^2+1 0*x+1,x^10+10*x^9+45*x^8+120*x^7+210*x^6+252*x^5+210*x^4+120*x^3+45*x^2+10*x+ 1],[x^10+10*x^9+45*x^8+120*x^7+210*x^6+252*x^5+210*x^4+120*x^3+45*x^2+10*x+1, x^10+10*x^9+45*x^8+120*x^7+210*x^6+252*x^5+210*x^4+120*x^3+45*x^2+10*x+1]])"
Type: String

OPEN QUESTIONS

  • is there a way not to break numbers?
  • is there a way to )set 1D output once for all without macros?




  Subject:   Be Bold !!
  ( 15 subscribers )  
Please rate this page: