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

 Description   

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

Demonstration:

(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



 Comments   
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 ]

Screened.

Generated at Fri Oct 24 19:44:20 CDT 2014 using JIRA 4.4#649-r158309.