Skip to content

Instantly share code, notes, and snippets.

@ztellman
Created January 7, 2015 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ztellman/4d77bbee001694307155 to your computer and use it in GitHub Desktop.
Save ztellman/4d77bbee001694307155 to your computer and use it in GitHub Desktop.
(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