ClojureScript

clojure.core.reducers/fold broken

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test

Description

clojure.core.reducers/fold currently does not work correctly if both a reducef and combinef are passed as arguments.

It is expected that (r/fold + + [1 2 3]) would return 6 (as do (r/fold + [1 2 3]) and (r/reduce + [1 2 3])). However, this is not the case because reducers.cljs currently defines fold as follows:

(def fold reduce)

As a result, the second + is used as the initial value for the reduce operation (instead of the value returned by ).

The attached patch fixes this bug. It also adds support for the protocol CollFold in CLJS.

(I will send in the CA tomorrow.)

  1. cljs_700.patch
    29/Nov/13 3:58 PM
    5 kB
    Jonas De Vuyst
  2. cljs-fold-fix.patch
    27/Nov/13 12:53 AM
    4 kB
    Jonas De Vuyst
  3. cljs-fold-fix-2.patch
    29/Nov/13 1:45 PM
    4 kB
    Jonas De Vuyst

Activity

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: