(partition n ch)
(partition n ch buf-or-n)
Deprecated - this function will be removed. Use transducer instead
Source
(defn
partition
"Deprecated - this function will be removed. Use transducer instead"
([n ch] (partition n ch nil))
([n ch buf-or-n]
(let
[out (chan buf-or-n)]
(go
(loop
[arr (make-array n) idx 0]
(let
[v (<! ch)]
(if
(not (nil? v))
(do
(aset arr idx v)
(let
[new-idx (inc idx)]
(if
(< new-idx n)
(recur arr new-idx)
(do (>! out (vec arr)) (recur (make-array n) 0)))))
(do (when (> idx 0) (>! out (vec arr))) (close! out))))))
out)))