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
(require 'clojure.core.async :refer :all) | |
(def MOVES [:rock :paper :scissors]) | |
(def BEATS {:rock :scissors, :paper :rock, :scissors :paper}) | |
(defn rand-player | |
"Create a named player and return a channel to report moves." | |
[name] | |
(let [out (chan)] | |
(go (while true (>! out [name (rand-nth MOVES)]))) |