(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"
{:deprecated "0.1.319.0-6b1aca-alpha"}
([f ch]
(partition-by f ch nil))
([f ch buf-or-n]
(let [out (chan buf-or-n)]
(go (loop [lst (ArrayList.)
last ::nothing]
(let [v (<! ch)]
(if (not (nil? v))
(let [new-itm (f v)]
(if (or (= new-itm last)
(identical? last ::nothing))
(do (.add ^ArrayList lst v)
(recur lst new-itm))
(do (>! out (vec lst))
(let [new-lst (ArrayList.)]
(.add ^ArrayList new-lst v)
(recur new-lst new-itm)))))
(do (when (> (.size ^ArrayList lst) 0)
(>! out (vec lst)))
(close! out))))))
out)))