tabulate

Make a sequence by performing a function on the index.

This function makes a sequence of type type whose i-th element is func(i) for 0 <= i < lengthType must be a subtype of <mutable-sequence>.

For example, I want a vector of the annual worth of an account of $10000 earning 10 percent annually.  The below code creates that vector:

tabulate(10, method(x) 10000 * exp(x * .1) end, type: <vector>)

Or, to create a list of factorials, one could write this:

define function factorial(x :: limited(<integer>, min: 0))
=> (y :: <integer>)
if(x == 0)
1;
else
reduce1(\*, tabulate(x, curry(\+, 1)));
end if;
end function factorial;

tabulate(6, factorial);

Exported from

Arguments

lengthAn instance of <integer>.
funcAn instance of <function>.  The signature of func is (<integer>) => (<object>).
type:An instance of <type>, a subclass of <mutable-sequence>.  The default is <list>.

Values

listAn instance of <mutable-sequence>.
The class of sequences that may be modified.
Sequence-Utilities, written by Matthias Hölzl, provides common or oft-used operations performed on <sequence>s.
The class of integers.
The class of objects that can be applied to arguments.
The class of all Dylan objects.
The class of all types, including classes and other types.
The class of linked lists.