|
  
makelist
Format: makelist( f(x), x, x1, x2,
step )
Arguments: [any] f(x) Function or expression
(node) x Name of the input variable in f(x)
(num) x1 Lower limit
(num) x2 Upper limit
(num) step Optional step size; default = 1
Returns: [any] A list of f(x) where x is
equal to all numbers from x1 to x2 inclusive, in
increments of step
Description: Makelist creates a temporary variable
named x and then constructs a list by setting x
equal to all numbers from x1 to x2 and repeatedly
evaluating f(x). That is, makelist(f(x),x,x1,x2)
= [f(x),f(x+1),...,f(x2)]
If a node named x already exists, it is replaced for
all evaluations of f(x) and is then restored to its
original state.
Note: If the expression f(x) is a tree node
rather than a function based on x, the reset primitive must be used to
cause the tree to recalculate on each iteration. Constants retain
their value from the first evaluation and return this value on
all subsequent evaluations. To cause the constant to be
reevaluated, use an expression similar to
makelist({reset,f},x,x1,x2)
rather than
makelist(f,x,x1,x2)
Examples: makelist(n,n,3,7) =
[3,4,5,6,7]
makelist(n^2,n,1,4) = [1,4,9,16]
makelist(rand,n,1,10) = list
of 10 random numbers
See Also: Range, each, both, sigma
|