Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created July 5, 2013 18:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swannodette/5936249 to your computer and use it in GitHub Desktop.
Save swannodette/5936249 to your computer and use it in GitHub Desktop.
(defn put-all! [cs x]
(doseq [c cs]
(put! c x)))
(defn multiplex [in cs-or-n]
(let [cs (if (number? cs-or-n)
(repeatedly cs-or-n chan)
cs-or-n)]
(go (loop []
(let [x (<! in)]
(if-not (nil? x)
(do
(put-all! cs x)
(recur))
:done))))
cs))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment