Maxima Function
create_list (form, x_1, list_1, ..., x_n, list_n)
Create a list by evaluating form with x_1 bound to each element of list_1, and for each such binding bind x_2 to each element of list_2, .... The number of elements in the result will be the product of the number of elements in each list. Each variable x_i must actually be a symbol -- it will not be evaluated. The list arguments will be evaluated once at the beginning of the iteration.
(%i1) create_list(x^i,i,[1,3,7]); 3 7 (%o1) [x, x , x ]
With a double iteration:
(%i1) create_list([i,j],i,[a,b],j,[e,f,h]); (%o1) [[a, e], [a, f], [a, h], [b, e], [b, f], [b, h]]
Instead of list_i two args may be supplied each of which should evaluate to a number. These will be the inclusive lower and upper bounds for the iteration.
(%i1) create_list([i,j],i,[1,2,3],j,1,i); (%o1) [[1, 1], [2, 1], [2, 2], [3, 1], [3, 2], [3, 3]]
Note that the limits or list for the j
variable can
depend on the current value of i
.