Clojure

`reductions should respect `reduced

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Critical Critical
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: Release 1.7
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Screened

Description

This returns 16:

(reduce (fn [acc x]
          (let [x' (* x x)]
            (if (> x' 10)
              (reduced x')
              x')))
        (range))

But replacing reduce with reductions will never terminate:

(reductions (fn [acc x]
              (let [x' (* x x)]
                (if (> x' 10)
                  (reduced x')
                  x')))
            (range))

Cause: reductions ignores clojure.lang.Reduced, it never tests for reduced?

Patch: CLJ-1181-v002.patch

Screened by: Alex Miller

  1. CLJ-1181-v001.patch
    16/Mar/13 6:10 PM
    1.0 kB
    Brandon Bloom
  2. CLJ-1181-v002.patch
    14/Jun/14 4:10 PM
    2 kB
    Brandon Bloom

Activity

People

Vote (4)
Watch (2)

Dates

  • Created:
    Updated: