clojure / clojure/clojure-site

reducers example isn't parallel

Open
#377 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
Dominant language
HTML
Stars
259
Forks
275
PR merge metrics
No merged PRs in 30d

Description

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).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the reducers reference page linked in the issue and find the foldcat example using (range 100000). Update the example so it uses a vector for parallel folding and retain a concise explanatory comment; done means the page no longer presents a sequential range as a parallel example.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.