Skip to content

Instantly share code, notes, and snippets.

@m0smith
m0smith / rps.clj
Last active December 19, 2015 16:59 — forked from puredanger/rps.clj
(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)])))