You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to find a simple way to fold a stream into a single value.
Currently the only way to do that is by having an intermediate list:
$ echo 1 2 3 4 5 | R --slurp sum
15
Transducers (and transduce-stream) offer a way to map and filter a stream without creating an intermediate collections, but they don't seem like a solution in this case. It would probably require some kind of reducing transformer just before transduce-stream pushes values to the next stream. Reducing transformer seems unorthodox because normally you'd just use a reduce iterator with transduce.
Investigate possibility of parameterizing a custom reduce stream.
Along the lines of but something nicer than:
$ echo| R inc --reduce-fn 'add' --reduce-acc '0'
20
The text was updated successfully, but these errors were encountered:
I'd like to find a simple way to fold a stream into a single value.
Currently the only way to do that is by having an intermediate list:
Transducers (and
transduce-stream
) offer a way to map and filter a stream without creating an intermediate collections, but they don't seem like a solution in this case. It would probably require some kind of reducing transformer just beforetransduce-stream
pushes values to the next stream. Reducing transformer seems unorthodox because normally you'd just use a reduce iterator withtransduce
.Investigate possibility of parameterizing a custom reduce stream.
Along the lines of but something nicer than:
The text was updated successfully, but these errors were encountered: