(partition-by f ch)
(partition-by f ch buf-or-n)
Deprecated - this function will be removed. Use transducer instead
Source
(defn
partition-by
"Deprecated - this function will be removed. Use transducer instead"
([f ch] (partition-by f ch nil))
([f ch buf-or-n]
(let
[out (chan buf-or-n)]
(go
(loop
[lst (make-array 0) last :clojure.core/nothing]
(let
[v (<! ch)]
(if
(not (nil? v))
(let
[new-itm (f v)]
(if
(or
(= new-itm last)
(keyword-identical? last :clojure.core/nothing))
(do (.push lst v) (recur lst new-itm))
(do
(>! out (vec lst))
(let
[new-lst (make-array 0)]
(.push new-lst v)
(recur new-lst new-itm)))))
(do
(when (> (alength lst) 0) (>! out (vec lst)))
(close! out))))))
out)))