6.40.2 Making a list with a function: makelist
The makelist command creates lists built from values of a
function.
-
makelist takes three mandatory arguments and one
optional argument:
-
f, a function (see Section 6.15.1).
- a and b, two real numbers.
- Optionally p, a step size (by default 1 if b>a and
−1 if b < a).
- makelist(f,a,b ⟨,p⟩) returns the
list [f(a),f(a+p),…,f(a+k p)] with k such
that: a<a+k p ≤ b <a+(k+1) p or a>a+k p ≥ b >a+(k+1) p.
Examples.
(In these examples, purge x if x is not symbolic.)
-
Input:
makelist(x->x^2,3,5)
or:
makelist(x->x^2,3,5,1)
or:
Input:
h(x):=x^2 |
makelist(h,3,5,1)
|
Output:
- Input:
makelist(x->x^2,3,6,2)
Output:
- Input:
makelist(4,1,3)
regards 4 as the constant function, and so creates a list with entries
4, from integers 1 to 3. This is the same as [4 $ 3].
Output: