Handbook
Glossary
produce-as ( ..a pred: ( ..a -- ..b ? ) quot: ( ..b -- ..a obj ) exemplar -- ..b seq )
Factor handbook
»
The language
»
Collections
»
Sequence operations
»
Sequence combinators
Prev:
produce ( ..a pred: ( ..a -- ..b ? ) quot: ( ..b -- ..a obj ) -- ..b seq )
Next:
sum ( seq -- n )
Vocabulary
sequences
Inputs
pred
a
quotation
with stack effect
( ..a -- ..b ? )
quot
a
quotation
with stack effect
( ..b -- ..a obj )
exemplar
a
sequence
Outputs
seq
a
sequence
Word description
Calls
pred
repeatedly. If the predicate yields
f
, stops, otherwise, calls
quot
to yield a value. Values are accumulated and returned in a sequence of type
exemplar
at the end.
Examples
See
produce
for examples.
Definition
USING:
kernel
;
IN:
sequences
:
produce-as
( ..a pred: ( ..a -- ..b ? ) quot: ( ..b -- ..a obj ) exemplar -- ..b seq )
dup
[
collector-as
[
while
]
dip
]
curry
dip
like
;
inline