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 -- ..b intermediate ) reduce-quot: ( ..b 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 )


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 )


Testing if a sequence contains elements satisfying a predicate:
any? ( ... seq quot: ( ... elt -- ... ? ) -- ... ? )

all? ( ... seq quot: ( ... elt -- ... ? ) -- ... ? )


Related Articles
Pair-wise sequence combinators
Triple-wise sequence combinators