sum ( seq -- n )
Factor handbook » The language » Collections » Sequence operations » Sequence combinators

Prev:produce-as ( ..a pred: ( ..a -- ..b ? ) quot: ( ..b -- ..a obj ) exemplar -- ..b seq )
Next:product ( seq -- n )


Vocabulary
sequences

Inputs
seqa sequence of numbers


Outputs
na number


Word description
Outputs the sum of all elements of seq. Outputs zero given an empty sequence.

Examples
USING: prettyprint sequences ; { 3 1 5 } sum .
9

USING: prettyprint sequences ; { } sum .
0


Definition


Methods