Skip to content

Instantly share code, notes, and snippets.

@noisesmith
Created January 21, 2016 23:33
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 noisesmith/4fb0b6fec934128d89e1 to your computer and use it in GitHub Desktop.
Save noisesmith/4fb0b6fec934128d89e1 to your computer and use it in GitHub Desktop.
clojure core.async/reduce
user=> (require '[clojure.core.async :as >])
nil
user=> (def c (>/chan))
#'user/c
user=> (def s (>/reduce str "" c))
#'user/s
user=> (>/>!! c "hello")
true
user=> (>/>!! c ", ")
true
user=> (>/>!! c "world!")
true
user=> (>/close! c)
nil
user=> (>/<!! s)
"hello, world!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment