<< Back to previous view

[CLJ-1160] reducers/mapcat ignores Reduced Created: 11/Feb/13  Updated: 14/Aug/13  Resolved: 14/Aug/13

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: Release 1.5
Fix Version/s: Release 1.6

Type: Defect Priority: Major
Reporter: Christophe Grand Assignee: Christophe Grand
Resolution: Completed Votes: 1
Labels: None

Attachments: File lazy-rmapcat2.diff     File lazy-rmapcat.diff    
Patch: Code and Test
Approval: Ok


Problem: clojure.core.reducers/mapcat does not stop on reduced? values.


(require '[clojure.core.reducers :as r])

(->> (concat (range 100) (lazy-seq (throw (Exception. "Too eager"))))
             (r/mapcat (juxt inc str))
             (r/take 5)
             (into []))
;; Exception Too eager

;; Expected return value: [1 "0" 2 "1" 3]

Cause: r/mapcat introduces an intermediate reduce which swallows the reduced value coming from r/take.

Patch: lazy-rmapcat2.diff

Comment by Stuart Sierra [ 02/Aug/13 2:31 PM ]

Cleaned up description.

Comment by Stuart Sierra [ 02/Aug/13 2:36 PM ]

Original patch lazy-rmapcat.diff had whitespace errors, which I have fixed in a new patch lazy-rmapcat2.diff. I also added the ticket number to the commit message.

Comment by Stuart Sierra [ 02/Aug/13 2:37 PM ]


Generated at Sun Apr 21 13:59:16 CDT 2019 using JIRA 4.4#649-r158309.