Skip to content

Commit 703561b

Browse files
brandonbloomswannodette
authored andcommitted
CLJS-1239: Make eduction variadic.
1 parent 5f1bf1e commit 703561b

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/cljs/cljs/core.cljs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8944,11 +8944,13 @@ reduces them without incurring seq initialization"
89448944
(es6-iterable Eduction)
89458945

89468946
(defn eduction
8947-
"Returns a reducible/iterable/seqable application of
8948-
the transducer to the items in coll. Note that these applications
8949-
will be performed every time iterator/seq/reduce is called."
8950-
[xform coll]
8951-
(Eduction. xform coll))
8947+
"Returns a reducible/iterable application of the transducers
8948+
to the items in coll. Transducers are applied in order as if
8949+
combined with comp. Note that these applications will be
8950+
performed every time reduce/iterator is called."
8951+
{:arglists '([xform* coll])}
8952+
[& xforms]
8953+
(Eduction. (apply comp (butlast xforms)) (last xforms)))
89528954

89538955
(defn run!
89548956
"Runs the supplied procedure (via reduce), for purposes of side

test/cljs/cljs/core_test.cljs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,7 @@
13691369
(is (= (sequence (mapcat reverse) [[3 2 1 0] [6 5 4] [9 8 7]])
13701370
(range 10)))
13711371
(is (= (seq (eduction (map inc) [1 2 3])) '(2 3 4)))
1372+
(is (= (seq (eduction (map inc) (map inc) [1 2 3])) '(3 4 5)))
13721373
(is (= (sequence (partition-by #{:split}) [1 2 3 :split 4 5 6])
13731374
'([1 2 3] [:split] [4 5 6])))
13741375
(is (= (sequence (partition-all 3) '(1 2 3 4 5))

0 commit comments

Comments
 (0)