Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created August 13, 2013 03:55
Show Gist options
  • Save swannodette/6217767 to your computer and use it in GitHub Desktop.
Save swannodette/6217767 to your computer and use it in GitHub Desktop.
(defn take-until
([pred-sentinel in] (take-until pred-sentinel in (chan)))
([pred-sentinel in out]
(go (loop []
(if-let [v (<! in)]
(do
(>! out v)
(if-not (pred-sentinel v)
(recur)
(close! out)))
(close! out))))
out))
(defn siphon
([in] (siphon in []))
([in coll]
(go (loop [coll coll]
(if-let [v (<! in)]
(recur (conj coll v))
coll)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment