Making sequences with variables
Factor handbook » The language » Collections

Prev:Virtual sequences
Next:Arrays


The make vocabulary implements a facility for constructing sequences and assocs by holding a collector object in a variable. Storing the collector object in a variable rather than the stack may allow code to be written with less stack manipulation.

Object construction is wrapped in a combinator:
Image
make ( quot exemplar -- seq )


Inside the quotation passed to make, several words accumulate values:
Image
, ( elt -- )

Image
% ( seq -- )

Image
# ( n -- )


When making an assoc, you can use these words to add key/value pairs:
Image
,, ( value key -- )

Image
%% ( assoc -- )


The collector object can be accessed directly from inside a make:
Image
building


USING: make math.parser ; [ "Language #" % CHAR: \s , 5 # ] "" make print
Language # 5

Image Make philosophy