0

I have seen that there are two similar functions to create lists in maxima: create_list() and makelist(). In both cases, the arguments can be

  1. (<an expression>, <a variable>, <the initial value>, <the final value>, < the step>) or
  2. (<an expression>, <a variable>, <a list of values for the variable>).

What is the difference between these two functions? I have tried a couple of examples and they seem to work in the same way:

makelist(i^i,i,1,3); -> [1,4,27]

create_list(i^i,i,1,3); -> [1,4,27]

makelist(i^i,i,[1,2,3]); -> [1,4,27]

create_list(i^i,i,[1,2,3]); -> [1,4,27]

User1234321
  • 321
  • 1
  • 10
  • The documentation explains well the use case of each, what is unclear? It is not that both gave the same result that there is no difference: https://maxima.sourceforge.io/docs/manual/maxima_21.html – Vega Jun 05 '22 at 11:08
  • Also https://maxima-discuss.narkive.com/3g8egf0q/makelist-vs-create-list – Vega Jun 05 '22 at 11:08
  • 1
    The useful thing about `create_list`, compared to `makelist`, is that `create_list` allows multiple iteration variables. But it's more than a little messy, as mentioned in the email (https://maxima-discuss.narkive.com/3g8egf0q/makelist-vs-create-list) linked by Vega. – Robert Dodier Jun 06 '22 at 16:59

1 Answers1

1

If you wish, you can create your own function, with its own syntax, in maxima. For example, there is no operator ".." but this makes it happen.

infix("..",80,80,expr,expr,expr);

You can then define the semantics ...

here I just call a function named range.

(a..b):= range(a,b)

This doesn't provide for all the embroidery that you might like.

I think a superior technique for syntax and semantics is to enhance the "for" loop as in this example:

for i:1 thru 5 do collect i;

which returns [1,2,3,4,5]

All the varied mechanisms for "for", including step size, limit, iterating through sets, etc. can then be included in computing a list explicitly comprising a range. The code for this is about 7 lines of lisp, inserted into the source code for "parse-$do". I also allow

for i in [a,b] summing f(i) ; which returns f(b)+f(a).

This enhancement is redundant for the (few) people who are comfortable with map, cons, lambda, apply, append ... in Maxima.

The code, which can be read in to any maxima, is here.

https://people.eecs.berkeley.edu/~fateman/lisp/doparsesum.lisp

Richard Fateman
  • 256
  • 1
  • 1