Created
July 21, 2013 04:33
-
-
Save Jared314/6047489 to your computer and use it in GitHub Desktop.
Clojure core.async example 2
This file contains hidden or 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 async2 | |
(:require [clojure.core.async :as async] | |
[clojure.core.async.lab :as lab])) | |
(defn make-fb-group [& members] | |
(apply lab/broadcast members)) | |
(defn alice [c] | |
(async/>!! c "Dave Davenson's House @ 10pm")) | |
(defn bob [] | |
(let [c (async/chan 1)] | |
(async/go (println "Bob received: " (async/<! c))) | |
c)) | |
(defn carol [] | |
(let [c (async/chan 1)] | |
(async/go (println "Carol received: " (async/<! c))) | |
c)) | |
(let [fb-group (make-fb-group (bob) (carol))] | |
; Alice sends the message to the group | |
(alice fb-group)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment