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

Prev:partition ( ... seq quot: ( ... elt -- ... ? ) -- ... trueseq falseseq )
Next:replicate-as ( ... len quot: ( ... -- ... newelt ) exemplar -- ... newseq )


Vocabulary
sequences

Inputs and outputs
lenan integer
quota quotation with stack effect ( ... -- ... newelt )
newseqa sequence


Word description
Calls the quotation len times, collecting results into a new array.

Examples
USING: kernel prettyprint random sequences ; 5 [ 100 random ] replicate .
{ 52 10 45 81 30 }


See also
replicate-as

Definition

: replicate
( ... len quot: ( ... -- ... newelt ) -- ... newseq )
{ } replicate-as ; inline