accumulate*-as ( ... seq identity quot: ( ... prev elt -- ... next ) exemplar -- ... newseq )
Factor handbook » The language » Collections » Sequence operations » Sequence combinators

Prev:accumulate* ( ... seq identity quot: ( ... prev elt -- ... next ) -- ... newseq )
Next:filter ( ... seq quot: ( ... elt -- ... ? ) -- ... subseq )


Vocabulary
sequences

Inputs
seqa sequence
identityan object
quota quotation with stack effect ( ... prev elt -- ... next )
exemplara sequence


Outputs
newseqa new sequence


Word description
Combines successive elements of the sequence using a binary operation, and outputs a sequence of the same type as exemplar containing all results.

On the first iteration, the two inputs to the quotation are identity and the first element of the input sequence. On successive iterations, the first input is the result of the previous iteration, and the second input is the next element of the input sequence.

When given the empty sequence, outputs a new empty sequence

Notes
May be named scan or prefix sum in other languages.

See also
accumulate, accumulate!, accumulate-as, accumulate*, accumulate*!

Definition


: accumulate*-as
( ... seq identity quot: ( ... prev elt -- ... next ) exemplar -- ... newseq )
[ (accumulate*) ] dip map-as nip ; inline