# [Maxima] New function - makelist alternative: table()

Žiga Lenarčič ziga.lenarcic at gmail.com
Sun May 10 09:10:58 CDT 2009

```> Looks like a good idea. Here are some comments..
>
> But Table[i,{i,10,0,-1}] works for Mathematica. Will your program work
> with negative step?

It works, of course. I have made some corrections to table.lisp on my
computer, so that now variables bound in previous iterators are used
for evaluating next iterator, so something like
table(sin(t), [step, [0.1, 0.2, 0.5]], [t,0,10, step]);
works correctly.
I have still some problems with bigfloats, problably 'mlsp' and
'mgrp' comparisons give wrong results, not sure yet.
Besides that it works as advertised (like Table[], except in some
error cases where Mathematica returns an empty list, rather than
reporting an error).

> Another thought would be to extend for ...do   based on Lisp's
> extensive
> iteration "loop"  macro using keywords.  e.g.
>
> for i:1 thru 10 step -1 collect i    .... which is sort of the same as
> table??
>
>
> for i:1 thru 10 sum i   ....                 like sum(i,i,1,10) except
> no effort for closed form?
> for i:1 thru 10 product i
> for i:1 thru 10 maximize f(i)
> for i:1 thru 10 count oddp(f(i))
> for i:1 thru 10 until f(i)>2 do print(g(i))
>
> for r in [a,b,c].

These would be nice too (python like). I find Maximas 'for' and 'if'
constructs very hard to use, because these keywords are not that
clear to me(what gets evaluated in what way). I wouldn mind something
like Mathematica's iteration: Do[ program, {i,1,100}]; or If[test,
then, else]; Functional form seems more clear to me (even for if
sentences).

> While Mathematica has many nice features, its syntax is hardly its
> high
> point. In fact it tends to be cryptic.
> It it Lisp-like in promoting functional application, but uses
> f[g[x,y]]  instead of (f (g x y)).  That's OK with
> me as a lisp programmer.  I don't like the infix operators of
> mysterious
> precedence, like =,==, ===, _ , __, ___, #,& ,@, /, //, ./, ....

Infix syntax, as you stated, can be unclear. But Mathematica avoids
that by allowing both 'prefix' and 'infix' notation for every
operation. So the user has a choice to use 'contracted' form or the
long and precise form. I think that is the best solution (to offer
both). I haven't had any problems using mathematicas anonymous
functions like (#^2)& - adding a pair of parenthesis seems enough
clear to me. I miss this in Maxima.
But I agree that prefix notation is the most clear, though a choice
is welcome - otherwise everybody would write their programs in Lisp :).

> Or maybe just have iterators optionally like  [index=i, first=0,
> last=10,step=1, direction=up]  instead of [i,0,10,1].
> Could be [i,last=10].

I like Mathematica's consistent use of iterators very much, I miss it
in Maxima. I find them very clear, since they always intuitively work
(for me, at least).
[100] clearly implies that no variable is bound.
[i, 100] is not very clear of the lower limit (is it 0 or 1), but the
user can always type
[i,1 ,100] to be sure. I like this.
Besides [] brackets add a visual clue which numbers are related to a
certain variable, which I like too.

Regards,
Ziga Lenarcic
```