Clojure

reducers/mapcat ignores Reduced

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: Release 1.5
  • Fix Version/s: Release 1.6
  • Component/s: None
  • Labels:
    None
  • 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

  1. lazy-rmapcat.diff
    11/Feb/13 8:38 AM
    2 kB
    Christophe Grand
  2. lazy-rmapcat2.diff
    02/Aug/13 2:36 PM
    2 kB
    Stuart Sierra

Activity

Hide
Stuart Sierra added a comment -

Cleaned up description.

Show
Stuart Sierra added a comment - Cleaned up description.
Hide
Stuart Sierra added a comment -

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.

Show
Stuart Sierra added a comment - 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.
Hide
Stuart Sierra added a comment -

Screened.

Show
Stuart Sierra added a comment - Screened.

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: