Last active
February 5, 2018 11:28
-
-
Save mpenet/674c13bb8cc3b6fefa23f08bbea5446f to your computer and use it in GitHub Desktop.
like clojure.core sequence but without chunking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn unchunked-sequence [xform coll] | |
(->> coll | |
(clojure.lang.RT/iter) | |
(clojure.lang.TransformerIterator/create xform) | |
(clojure.lang.IteratorSeq/create))) | |
;; realizes 10 values | |
(first | |
(unchunked-sequence (comp (map #(do (prn %) %)) | |
(partition-all 10)) | |
(range 100))) | |
;; realizes all values | |
(first | |
(sequence (comp (map #(do (prn %) %)) | |
(partition-all 10)) | |
(range 100))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
since apparently sequence chunks by output it can end up causing the realisation of a lot of data from its inputs