Uploaded image for project: 'Clojure'
  1. CLJ-1185

`reductions should respect `reduced

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Completed
    • Affects versions: None
    • Fix versions: Release 1.7
    • Labels:
      None
    • Approval:
      Ok
    • Patch:
      Code and Test

      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

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              bbloom Brandon Bloom
            • Votes:
              2 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: