function | since v0.0-1236 | clojure.core.reducers/take | Edit |
(take n)
(take n coll)
Ends the reduction of coll after consuming n values.
(defcurried take
{}
[n coll]
(reducer coll
(fn [f1]
(let [cnt (atom n)]
(rfn [f1 k]
([ret k v]
(swap! cnt dec)
(if (neg? @cnt)
(reduced ret)
(f1 ret k v))))))))