-
-
Save rm-hull/7758795 to your computer and use it in GitHub Desktop.
Sample core.async - see it running in the browser: http://programming-enchiladas.destructuring-bind.org/rm-hull/7758795
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
(defn sin-vals [offset] | |
(map ƒ(Math/sin %) (iterate (partial + 0.1) offset))) | |
(let [events (chan)] | |
;; produce seqs of sine values | |
(go-loop [n 0] | |
(<! (timeout 200)) | |
(>! events (sin-vals n)) | |
(recur (inc n))) | |
(go-loop [cnt 10] | |
(when (pos? cnt) | |
;; Draw on screen | |
(println | |
(map (λ [x y] {:x x :y y}) | |
(range 3) | |
(take 3 (<! events)))) | |
(recur (dec cnt))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment