Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reducing stream without intermediate collections #4

Open
raine opened this issue Oct 20, 2015 · 0 comments
Open

Reducing stream without intermediate collections #4

raine opened this issue Oct 20, 2015 · 0 comments

Comments

@raine
Copy link
Owner

raine commented Oct 20, 2015

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant