reduce
accepts
1
input stream,
an accumulator
,
a seed
(optional)
seed
will be used as an initial accumulation accaccumulator
returns a new stream of accumulated values
scan
accepts
1
input stream,
an accumulator
,
a seed
(optional)
seed
will be used as an initial accumulation accaccumulator
returns a new stream of accumulated values
❚ reduce
takes the same three arguments as ❚ scan
:
character
to a string
)!
)As you can see, while ❚ scan
returns a new stream of progressively accumulated values, ❚ reduce
returns a new stream of, at most, one value. At most? If the input stream never completes, ❚ reduce
will never emit any value on the output stream.
Ultimately, ❚ reduce
is equivalent to ❚ scan
chained with ❚ takeLast(1)
.
Freelance Developer Advocate. Motion graphics with code. JavaScript and Elm. cedricsoulas.com
Receive my latest news, product updates and programming visualizations. You can unsubscribe at any time.