Created
January 7, 2015 06:36
-
-
Save ztellman/4d77bbee001694307155 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
(require | |
'[manifold.deferred :as d] | |
'[manifold.stream :as s]) | |
(defn take-first! [pred s] | |
(d/loop [] | |
(d/chain (s/take! s ::none) | |
#(cond | |
(identical? ::none %) | |
nil | |
(pred %) | |
% | |
:else | |
(d/recur))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment