makelist vs create_list



On 4/9/07, Robert Dodier <robert.dodier at gmail.com> wrote:
> To be clear, I want makelist to recognize arguments like this:
>   makelist (expr, i, i0, i1, j, j0, j1, k, k0, k1, ...)...
> makelist also recognizes makelist(expr, x, L) where L is a list.
> I guess I would suggest cutting that.

I would prefer to unify the two as follows:

        makelist(expr, i, ilist, j, jlist, ...)
==   makelist(expr, i, i0..i1, j, j0..j1, ...)

This is unambiguous.  Map of course can map over a list, but the
syntax is heavy: map(lambda([x],x^2),list) vs. makelist(x^2,x,list),
and the semantics are different in the multivariate case (see below).
Of course, the latter should be thought of as syntactic sugar for the
former.

> map(lambda([x], expr), L) has the same effect (ignoring
> evaluation subtleties) as makelist(expr, x, L) so we don't really
> need the latter, and map already allows multiple arguments too.

The multiple arguments to map have completely different semantics:

       map(f,[1,2],[3,4]) => [ f(1,3), f(2,4) ]
       create_list(f(a,b),a,[1,2],b,[3,4]) => [f(1, 3), f(1, 4), f(2,
3), f(2, 4)]

Both are useful.

> I've never liked the notation .. for an ellipsis.
> Why not type 3 dots and have a proper ellipsis.

Because (a) two dots for an integer range is established notation in
many languages (Pascal, Ada, Perl, Ruby, Maple); and (b) three dots is
generally used to mean something else both in mathematics and in
Maxima.

In mathematics, I don't think I've ever seen (m...n) to denote "the
integers from m to n"; instead, you see (m, m+1, ..., n); and in
general it has the rather vague meaning of "the reader can figure this
out", e.g. (1+a+...+a^n).

> Typing .. instead of ... is one of those unhelpful abbrvtions.

I don't think ".." is intended as an abbreviation of "..." but as a
distinct notation.

           -s