Skip to content

Instantly share code, notes, and snippets.

@michaelsbradleyjr
Last active August 29, 2015 14:20
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 michaelsbradleyjr/ca75a0d38e6e84cdabb4 to your computer and use it in GitHub Desktop.
Save michaelsbradleyjr/ca75a0d38e6e84cdabb4 to your computer and use it in GitHub Desktop.
(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