Last active
January 2, 2016 21:29
-
-
Save stuartsierra/8364220 to your computer and use it in GitHub Desktop.
concat in Clojure core.async (untested)
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
;; Totally untested | |
(defn concat [& chans] | |
(let [out (chan)] | |
(go-loop [[ch & more] chans] | |
(when ch | |
(let [val (<! ch)] | |
(if (nil? val) | |
(recur more) | |
(do (>! out val) | |
(recur chans)))))) | |
out)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment