Handbook
Glossary
Sequence combinators
Factor handbook
»
The language
»
Collections
»
Sequence operations
Prev:
Accessing sequence elements
Next:
Adding and removing sequence elements
Iteration:
each
( ... seq quot: ( ... x -- ... ) -- ... )
each-index
( ... seq quot: ( ... elt index -- ... ) -- ... )
reduce
( ... seq identity quot: ( ... prev elt -- ... next ) -- ... result )
interleave
( ... seq between quot: ( ... elt -- ... ) -- ... )
Mapping:
map
( ... seq quot: ( ... elt -- ... newelt ) -- ... newseq )
map-as
( ... seq quot: ( ... elt -- ... newelt ) exemplar -- ... newseq )
map-index
( ... seq quot: ( ... elt index -- ... newelt ) -- ... newseq )
map-index-as
( ... seq quot: ( ... elt index -- ... newelt ) exemplar -- ... newseq )
map-reduce
( ..a seq map-quot: ( ..a elt -- ..a intermediate ) reduce-quot: ( ..a prev intermediate -- ..a next ) -- ..a result )
accumulate
( ... seq identity quot: ( ... prev elt -- ... next ) -- ... final newseq )
accumulate-as
( ... seq identity quot: ( ... prev elt -- ... next ) exemplar -- ... final newseq )
accumulate*
( ... seq identity quot: ( ... prev elt -- ... next ) -- ... newseq )
accumulate*-as
( ... seq identity quot: ( ... prev elt -- ... next ) exemplar -- ... newseq )
Filtering:
filter
( ... seq quot: ( ... elt -- ... ? ) -- ... subseq )
filter-as
( ... seq quot: ( ... elt -- ... ? ) exemplar -- ... subseq )
partition
( ... seq quot: ( ... elt -- ... ? ) -- ... trueseq falseseq )
Counting:
count
( ... seq quot: ( ... elt -- ... ? ) -- ... n )
Superlatives with
min
and
max
:
minimum
( seq -- elt )
minimum-by
( ... seq quot: ( ... elt -- ... x ) -- ... elt )
maximum
( seq -- elt )
maximum-by
( ... seq quot: ( ... elt -- ... x ) -- ... elt )
shorter
( seq1 seq2 -- seq )
longer
( seq1 seq2 -- seq )
shorter?
( seq1 seq2 -- ? )
longer?
( seq1 seq2 -- ? )
shortest
( seqs -- elt )
longest
( seqs -- elt )
Generating:
replicate
( ... len quot: ( ... -- ... newelt ) -- ... newseq )
replicate-as
( ... len quot: ( ... -- ... newelt ) exemplar -- ... newseq )
produce
( ..a pred: ( ..a -- ..b ? ) quot: ( ..b -- ..a obj ) -- ..b seq )
produce-as
( ..a pred: ( ..a -- ..b ? ) quot: ( ..b -- ..a obj ) exemplar -- ..b seq )
Math:
sum
( seq -- n )
product
( seq -- n )
Testing if a sequence contains elements satisfying a predicate:
any?
( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
all?
( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
none?
( ... seq quot: ( ... elt -- ... ? ) -- ... ? )
Related Articles
Pair-wise sequence combinators
Triple-wise sequence combinators