Clojure core.async example 3
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 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