Handbook
Glossary
Making sequences with variables
Factor handbook
»
The language
»
Collections
Prev:
Virtual sequences
Next:
Arrays
The
make
vocabulary implements a facility for constructing
sequence
s and
assoc
s 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:
make
( quot exemplar -- seq )
Inside the quotation passed to
make
, several words accumulate values:
,
( elt -- )
%
( seq -- )
#
( n -- )
When making an
assoc
, you can use these words to add key/value pairs:
,,
( value key -- )
%%
( assoc -- )
The collector object can be accessed directly from inside a
make
:
building
USING: make math.parser ; [ "Language #" % CHAR: \s , 5 # ] "" make print
Language # 5
Make philosophy