6.3.2 Creating a list by using a function
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 8.2.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.)
or:
or:
h(x):=x^2:;
makelist(h,3,5,1) |
The above command line
regards 4 as the constant function, and so creates a list with entries
4, from integers 1 to 3. The command
is an equivalent.