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:any? ( ... seq quot: ( ... elt -- ... ? ) -- ... ? )


Vocabulary
sequences

Inputs and outputs
preda quotation with stack effect ( ..a -- ..b ? )
quota quotation with stack effect ( ..b -- ..a obj )
exemplara sequence
seqa 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


: produce-as
( ..a pred: ( ..a -- ..b ? ) quot: ( ..b -- ..a obj ) exemplar -- ..b seq )
dup [ collector-as [ while ] dip ] curry dip like ; inline