Skip to content

Fix reducers foldcat example to actually fold in parallel#741

Open
kovan wants to merge 1 commit intoclojure:masterfrom
kovan:docs/fix-reducers-parallel-example
Open

Fix reducers foldcat example to actually fold in parallel#741
kovan wants to merge 1 commit intoclojure:masterfrom
kovan:docs/fix-reducers-parallel-example

Conversation

@kovan
Copy link

@kovan kovan commented Mar 14, 2026

The r/foldcat example used (range 100000) which returns a seq. Seqs do not implement CollFold and fall back to single-threaded reduce, making the example misleading on a page about parallel folding.

Wraps with vec so the example actually demonstrates parallel folding, and adds a note explaining the requirement.

Verified against reducers.clj: Object/coll-fold falls back to single reduce, while IPersistentVector/coll-fold performs parallel fork-join folding.

Fixes #377

The example used (range 100000) which returns a seq. Seqs do not
implement CollFold and fall back to single-threaded reduce, making
the foldcat example misleading on a page about parallel folding.

Wrap with vec so the example actually demonstrates parallel folding.
Add a note explaining that seqs must be converted to vectors first.

Verified against reducers.clj: Object/coll-fold (line 320) falls
back to single reduce, while IPersistentVector/coll-fold (line 326)
performs parallel fork-join folding.

Fixes clojure#377
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

Successfully merging this pull request may close these issues.

reducers example isn't parallel

1 participant