Last active
August 29, 2015 14:20
-
-
Save michaelsbradleyjr/ca75a0d38e6e84cdabb4 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
(ns some.core | |
(:refer-clojure :exclude [transduce]) | |
(:require [clojure.core.async :as async])) | |
;; ----------------------------------------------------------------------------- | |
(defn transduce | |
"An async transduce variant. Does not provide any special handling for steps | |
in xform that might return channels, i.e. steps should return/pass non-channel | |
values." | |
([xform f chan] (transduce xform f (f) chan)) | |
([xform f init chan] | |
(go (let [f (xform f) | |
ret (async/reduce f init chan)] | |
(f (<! ret)))))) | |
;; (transduce xform (completing conj) (async/merge [ch1 ch2 ch3 ...])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment