Create a gist now

Instantly share code, notes, and snippets.

@Jared314 /async3.clj
Last active Dec 20, 2015

What would you like to do?
Clojure core.async example 3
(ns async3
(:require [clojure.core.async :as async]))
(defn alice [c message]
(async/>!! c message))
(defn person [name c]
(async/go
(let [message (async/<! c)]
(println name " received: " message)
message)))
(def bob (partial person "Bob"))
(def carol (partial person "Carol"))
(def dave (partial person "Dave"))
(let [c (async/chan 1)]
(-> (bob c)
(carol)
(dave))
; Alice sends the message
(alice c "Eve Evenson's House @ 10pm"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment