Suppose I have list of two polynomials and want to print it. I will get multi line output:
> P<x> := PolynomialRing(Rationals());
> list := [x^2 - 2*x + 2, x^2 + x];
> print list;
[
x^2 - 2*x + 2,
x^2 + x
]
Even more:
> print x^2 - 2*x + 2, ",", x^2 + x;
x^2 - 2*x + 2
, x^2 + x
So after any polynomial (and may be some other type of objects) print statement (or underlying conversion polynomial to string) always put new line symbol.
My goal is to print all elements of list in one line, like this
> one_line_print(list);
[x^2 - 2*x + 2, x^2 + x]
Is it possible?
You can try the printf function. To format it exactly how you want you would type
If you have to do it a bunch of times, you can make this a procedure that takes your list as an argument and then prints it in the proper format.