Previous Up Next

2.37.35  Make a list with a function : makelist

makelist takes as argument a function f, the bounds a,b of an index variable and a step s (by default 1 or -1 depending on the bounds order).
makelist makes the list [f(a),f(a+p)...f(a+k*p)] with k such that : a<a+k*pb <a+(k+1)*p or a>a+k*pb >a+(k+1)*p.
Input :

makelist(x->x^2,3,5)

or

makelist(x->x^2,3,5,1)

or first define the function h(x)=x2 by h(x):=x^2 then input

makelist(h,3,5,1)

Output :

[9,16,25]

Input :

makelist(x->x^2,3,6,2)

Output :

[9,25]

Warning!!! purge x if x is not symbolic.


Previous Up Next