(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"
{:deprecated "0.1.319.0-6b1aca-alpha"}
([n ch]
(partition n ch nil))
([n ch buf-or-n]
(let [out (chan buf-or-n)]
(go (loop [arr (make-array Object n)
idx 0]
(let [v (<! ch)]
(if (not (nil? v))
(do (aset ^objects arr idx v)
(let [new-idx (inc idx)]
(if (< new-idx n)
(recur arr new-idx)
(do (>! out (vec arr))
(recur (make-array Object n) 0)))))
(do (when (> idx 0)
(let [narray (make-array Object idx)]
(System/arraycopy arr 0 narray 0 idx)
(>! out (vec narray))))
(close! out))))))
out)))