Skip to content

reducers example isn't parallel #377

Open
@vemv

Description

@vemv

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions