(sorry about the new thread. my email was down for a day
and I didnt even get my own post. i picked this up from the archive)
First, thanks a bunch for the helpful leads.
>I'm not sure what you want, but it seems likely you want this
>custom loop to be a macro function (defined by ::=).
Great. I'll look at example code. Unfortunately the documentation on
macros is rather sparse.
>> f(expr) := create_list(expr,i,1,3);
>> f(i) --> [i, i, i]
>Maxima has 1-time evaluation. create_list evaluates expr with i bound
>to the values 1, 2, 3. expr is bound to the symbol i so in each case,
>create_list evaluates expr to i (which is not re-evaluated).
OK
>Incidentally the ev function recognizes a flag infeval which causes
>expressions to be evaluated until they stop changing.
I tried ev, but I'll revisit it with this flag.
>The subscript of a literal list must be a literal integer. I think that's
less
>useful than allowing a literal list to have a symbolic subscript. I've
>tinkered with code to change it but didn't finish it. I think I've floated
>the idea on this list before; I don't remember what came of it.
>I'm pretty sure create_list doesn't come into play in this case.
I guess it's not always clear when allowing a symbolic
argument is good behavior-- for cos(x) it's obviously a good
idea. (by the way, Mathematica shows the same behavior with
part() that Maxima currently shows.)
For expressions that cannot be evaluated with a symbolic argument
(such as m[i] or part(m,i) ), this fails:
f(expr) := apply('create_list, [expr,i,1,3]);
Problems like this come up quite a bit in what I'm doing-- maybe
a macro function, like you suggested above will help. But this
does work
create_list(part(m,i),i,1,3)
Since I am trying to create a list in a way slightly different than
create_list, I am giving up on Maxima and using the lisp code
for create_list as a model.
>I'm opposed to making Maxima splice in lists automatically.
>It seems like a minor convenience which makes Maxima's behavior
>inconsistent and therefore unnecessarily more difficult to explain.
Having Maxima splice lists automatically is a bad idea-- it
would surely break a lot of existing code. But it can make
dealing with a variable number of arguments easier. I was
thinking more along the lines of having some additional
facility.. maybe via new syntax. I don't know if integrating
Richard Fateman's pattern matching code with Maxima would be
problematic.
>> 4) Finally. I want to write something to do a general
>> transpose of a nested list.
>If the goal is to transpose a matrix which is represented
>by a nested list, then my advice is just work with a matrix.
No, what I meant was a nested list with more than two levels, like
what you might use to represent a tensor. So you might want to
transpose the second and third level, or do a more general permutation
of levels.(I should have said 'generalized transpose' instead of
'general transpose'.)
Thanks,
John