Yes, I should have mentioned this; the ?gensym() trick is
okay for internal computations that a user will never see,
but not a good choice for anything else. As you said, your
symbols only look the same; to see that
they are distinct, display them using ?print:
(%i1) ?gensym();
(%o1) G26937
(%i2) ?print(%);
#:G26937
(%o2) G26937
(%i3) g26937;
(%o3) g26937
(%i4) ?print(%);
|$g26937|
For symbols a user will see, something like the following might
work
(%i1) unk_index : -1;
(%o1) - 1
(%i2) next_unk() := concat("a", unk_index : unk_index + 1);
(%o2) next_unk() := CONCAT("a", unk_index : unk_index + 1)
(%i3) next_unk();
(%o3) a0
(%i4) next_unk();
(%o4) a1
Barton
Albert Reiner <areiner@tph.tuwien.ac.at>
Sent by: albert@berry.phys.ntnu.no
07/09/2004 10:51 AM
To: Barton Willis <willisb@unk.edu>
cc: maxima@www.ma.utexas.edu
Subject: Re: [Maxima] generate dummy variables
> > Is there a standard way for generating dummy variables that must be
> > unique? I am thinking of something akin to Common Lisp's GENSYM or
> > Mathematica's Unique[].
Barton Willis <willisb@unk.edu> writes:
> Lisp functions can be called from Maxima by adding '?' as
> a prefix to the function name. Thus to call the Lisp
> function gensym from Maxima, use ?gensym.
But the downside of this seems to be that I can and up with two
distinct symbols that appear the same on screen, which might be quite
confusing: