I have a solution to some problem:
solution := [z-4, 25-2*z, z]
And I'm trying to see what happens when 'z' runs from 0 to 9, so I do:
makelist(x->subst(solution, [z=x]), 0, 9)
This works ok. 'xcas' displays the big list as a nice matrix which is easy to read.
The problem is that in reality my 'solution' is the result of solve(). When this happens, 'xcas' doesn't print the big list as a nice matrix.
Example:
solution := solve([x+y+z=21,2x+3y+4z=67],[x,y,z])
makelist(x->subst(solution, [z=x]), 0, 9)
xcas now prints the big list on one line, which is hard to read.
Why is that? Doesn't solve() return a real list?
A problem formatting a list returned from solve()
Modérateur : xcasadmin
Re: A problem formatting a list returned from solve()
I've found the problem:
solve() returns a list of lists. So I have to use 'solution[0]', not 'solution'.
I wasn't aware of this because xcas displays this:
[[1,2,3]]
the same as this:
[1,2,3]
So I had no way of knowing there was a list inside
That's a big problem.
Why does xcas do this?
solve() returns a list of lists. So I have to use 'solution[0]', not 'solution'.
I wasn't aware of this because xcas displays this:
[[1,2,3]]
the same as this:
[1,2,3]
So I had no way of knowing there was a list inside
That's a big problem.
Why does xcas do this?
Re: A problem formatting a list returned from solve()
Aaahhh.....
I think I understand why xcas displays [[1,2,3]] the way it does: it's a matrix. One that happens to have a single row.
Still, it's problematic that we can't tell the difference between [1,2,3] and [[1,2,3]].
Is there a hidden configuration option to "fix" this?
I think I understand why xcas displays [[1,2,3]] the way it does: it's a matrix. One that happens to have a single row.
Still, it's problematic that we can't tell the difference between [1,2,3] and [[1,2,3]].
Is there a hidden configuration option to "fix" this?
Re: A problem formatting a list returned from solve()
It's not displayed exactly the same, if you look closely, you will see that for a 1-line matrix the delimiters are a little bigger than for a list.
Re: A problem formatting a list returned from solve()
Maybe the output would be more readable if the subtype of the result from solve was changed to _LIST__VECT?
That would, however, disable stacking the solutions one above another...
That would, however, disable stacking the solutions one above another...