Skip to content

Instantly share code, notes, and snippets.

Last active Aug 29, 2015
What would you like to do?
Just a quick demo of how the Clojure core.async merge function works. I wanted to check that the values from the input channels appear in the merged channel straight away.
(let [sleepy-val (fn [v t] (clojure.core.async/go
(clojure.core.async/<! (clojure.core.async/timeout t))
chans (clojure.core.async/merge (map #(sleepy-val % (rand-int 3000))
(range 10)))]
(while (when-let [v (clojure.core.async/<! chans)]
(prn v)
Copy link

msgodf commented Mar 5, 2014

I've intentionally namespace qualified each of the core.async functions here, so that it's a standalone sexpr without needing a require.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment