[Maxima] Push and pop in Maxima
ziga.lenarcic at gmail.com
Tue Sep 8 08:59:28 CDT 2009
On Sep 8, 2009, at 3:22 PM, Stavros Macrakis wrote:
> Your code will also create malformed expressions in some cases:
> ll:x^y$ push(3,ll) => 3^x ((mexpt simp) 3 $x $y). But mexpt takes
> exactly 2 arguments.
I see.. I don't even think a 'general' push/pop would be very useful
(one can always push onto a list and then when finished, apply a
function). Seems to me push/pop should only work on lists and perhaps
sets (again, perhaps not a good idea, since sets reorder elements) -
so unless $listp or $setp returns true, it should throw an error.
Since (meval 'expression') returns a simplified result, there is no
need to remove the simp flag when pushing onto a list, right?
> It is an error to use Lisp's push function to modify a Maxima
> variable. In particular, this means you can't push onto a subscripted
> variable: zz:$ push(3,zz) => error.
Ah, these are the cases I always forget about, because accessing a
maxima variable that is also a lisp variable is so easy to do. So in
this case I can get the attached list with 'meval', modify it, but
how do I then attach it back to the zz?
One way is probably by constructing a 'mset' expression and
evaluating it, but can we use something cheaper in this case (since
it is known what we want)?
To make a fast push/pop I would still have special code, when push/
pop gets a 'symbolp' (regular Maxima variable). In this case it's
probably OK to just use lisp's 'set'?
> I hope my comments help you understand how Maxima works internally
Thanks for clarifications, they are very useful.
More information about the Maxima