Skip to content

Commit 813e65a

Browse files
committed
simple vector missing IKVReduce & IComparable impls
1 parent 650fe98 commit 813e65a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12345,6 +12345,23 @@ reduces them without incurring seq initialization"
1234512345
(-reduce [v f start]
1234612346
(array-reduce array f start))
1234712347

12348+
IKVReduce
12349+
(-kv-reduce [v f init]
12350+
(let [len (alength array)]
12351+
(loop [i 0 init init]
12352+
(if (< i len)
12353+
(let [init (f init i (aget array i))]
12354+
(if (reduced? init)
12355+
@init
12356+
(recur (inc i) init)))
12357+
init))))
12358+
12359+
IComparable
12360+
(-compare [x y]
12361+
(if (vector? y)
12362+
(compare-indexed x y)
12363+
(throw (js/Error. "Cannot compare with Vector"))))
12364+
1234812365
IFn
1234912366
(-invoke [coll k]
1235012367
(-lookup coll k))

0 commit comments

Comments
 (0)