Skip to content

Instantly share code, notes, and snippets.

@rm-hull
Forked from martintrojer/sin.cljs
Last active December 30, 2015 01:49

Revisions

  1. rm-hull revised this gist Dec 2, 2013. 1 changed file with 7 additions and 6 deletions.
    13 changes: 7 additions & 6 deletions sin.cljs
    Original file line number Diff line number Diff line change
    @@ -15,9 +15,10 @@
    (>! events (sin-vals n))
    (recur (inc n))))

    (dotimes [_ 10]
    ;; Draw on screen
    (println
    (map (fn [x y] {:x x :y y})
    (range 3)
    (take 3 (<! events))))))
    (go
    (dotimes [_ 10]
    ;; Draw on screen
    (println
    (map (fn [x y] {:x x :y y})
    (range 3)
    (take 3 (<! events)))))))
  2. rm-hull revised this gist Dec 2, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions sin.cljs
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    (ns async-test.sinewave.core
    (:require [cljs.core.async :refer [<! <!! >! chan timeout]])
    (:require [cljs.core.async :refer [<! >! chan timeout]])
    (:require-macros
    [cljs.core.async.macros :as m :refer [go]]))

    @@ -20,4 +20,4 @@
    (println
    (map (fn [x y] {:x x :y y})
    (range 3)
    (take 3 (<!! events))))))
    (take 3 (<! events))))))
  3. rm-hull revised this gist Dec 2, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion sin.cljs
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    (ns async-test.sinewave.core
    (:require [cljs.core.async :refer [chan timeout]])
    (:require [cljs.core.async :refer [<! <!! >! chan timeout]])
    (:require-macros
    [cljs.core.async.macros :as m :refer [go]]))

  4. rm-hull revised this gist Dec 2, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion sin.cljs
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    (ns async-test.sinewave.core
    (:require [cljs.core.async :refer [chan close!]])
    (:require [cljs.core.async :refer [chan timeout]])
    (:require-macros
    [cljs.core.async.macros :as m :refer [go]]))

  5. rm-hull revised this gist Dec 2, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions sin.cljs
    Original file line number Diff line number Diff line change
    @@ -10,10 +10,10 @@
    (let [events (chan)]

    ;; produce seqs of sine values
    (go-loop [n 0]
    (go (loop [n 0]
    (<! (timeout 200))
    (>! events (sin-vals n))
    (recur (inc n)))
    (recur (inc n))))

    (dotimes [_ 10]
    ;; Draw on screen
  6. rm-hull revised this gist Dec 2, 2013. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion sin.cljs
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,10 @@
    defn sin-vals [offset]
    (ns async-test.sinewave.core
    (:require [cljs.core.async :refer [chan close!]])
    (:require-macros
    [cljs.core.async.macros :as m :refer [go]]))


    (defn sin-vals [offset]
    (map #(Math/sin %) (iterate (partial + 0.1) offset)))

    (let [events (chan)]
  7. @martintrojer martintrojer revised this gist Dec 2, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion sin.cljs
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,6 @@ defn sin-vals [offset]
    (dotimes [_ 10]
    ;; Draw on screen
    (println
    (map (λ [x y] {:x x :y y})
    (map (fn [x y] {:x x :y y})
    (range 3)
    (take 3 (<!! events))))))
  8. @martintrojer martintrojer revised this gist Dec 2, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion sin.cljs
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    defn sin-vals [offset]
    (map ƒ(Math/sin %) (iterate (partial + 0.1) offset)))
    (map #(Math/sin %) (iterate (partial + 0.1) offset)))

    (let [events (chan)]

  9. @martintrojer martintrojer revised this gist Dec 2, 2013. 1 changed file with 7 additions and 11 deletions.
    18 changes: 7 additions & 11 deletions sin.cljs
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    (defn sin-vals [offset]
    defn sin-vals [offset]
    (map ƒ(Math/sin %) (iterate (partial + 0.1) offset)))

    (let [events (chan)]
    @@ -9,13 +9,9 @@
    (>! 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)))))
    (dotimes [_ 10]
    ;; Draw on screen
    (println
    (map (λ [x y] {:x x :y y})
    (range 3)
    (take 3 (<!! events))))))
  10. @martintrojer martintrojer created this gist Dec 2, 2013.
    21 changes: 21 additions & 0 deletions sin.cljs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    (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)))))