Created
September 4, 2016 06:50
-
-
Save spacepluk/f20fc43fb702cf25d654e2fd0d86e058 to your computer and use it in GitHub Desktop.
This file contains 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 seq!! | |
"Returns a (blocking!) lazy sequence read from a channel." | |
[c] | |
(lazy-seq | |
(when-let [v (<!! c)] | |
(cons v (seq!! c))))) | |
(defn -main | |
[& args] | |
(let [c (chan)] | |
(future | |
(doseq [i (range 10)] | |
(>!! c i)) | |
(close! c)) | |
(doseq [s (seq!! c)] | |
(println s))) | |
(println "exit")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment