replicate-as ( ... len quot: ( ... -- ... newelt ) exemplar -- ... newseq )
Factor handbook » The language » Collections » Sequence operations » Sequence combinators

Prev:replicate ( ... len quot: ( ... -- ... newelt ) -- ... newseq )
Next:produce ( ..a pred: ( ..a -- ..b ? ) quot: ( ..b -- ..a obj ) -- ..b seq )


Vocabulary
sequences

Inputs
lenan integer
quota quotation with stack effect ( ... -- ... newelt )
exemplara sequence


Outputs
newseqa sequence


Word description
Calls the quotation len times, collecting results into a new sequence of the same type as the exemplar sequence.

Examples
USING: prettyprint kernel sequences ; 5 [ 100 random ] B{ } replicate-as .
B{ 44 8 2 33 18 }


See also
replicate

Definition


: replicate-as
( ... len quot: ( ... -- ... newelt ) exemplar -- ... newseq )
[ [ drop ] prepose ] dip map-integers-as ; inline