Skip to content

reducers example isn't parallel #377

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

Open
vemv opened this issue Mar 28, 2019 · 1 comment
Open

reducers example isn't parallel #377

vemv opened this issue Mar 28, 2019 · 1 comment

Comments

@vemv
Copy link

vemv commented Mar 28, 2019

The following example included in https://clojure.org/reference/reducers won't run in parallel because range is a seq:

(r/foldcat (r/filter even? (r/map inc (range 100000))))

It is confusing to find a "no-gain" example in a page explaining reducers.

Consequently, I'd suggest instead:

;; `vec` is there since seqs don't support parallel folding
(r/foldcat (r/filter even? (r/map inc (vec (range 100000)))))

Perhaps the comment would duplicate some information already in the page (If a collection does not support folding, it will fall back to non-parallel reduce instead.), but newcomers probably will appreciate a reminder (and an example).

@puredanger
Copy link
Member

Maybe should go further to find better example here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants