Skip to content

Instantly share code, notes, and snippets.

@stuarthalloway
Created July 18, 2013 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuarthalloway/6031376 to your computer and use it in GitHub Desktop.
Save stuarthalloway/6031376 to your computer and use it in GitHub Desktop.
;; proposed change #1, objective: make update to q more evident
(defn peekn
"Returns vector of (up to) n items from the end of vector v"
[v n]
(if (> (count v) n)
(subvec v (- (count v) n))
v))
(let [el (by-id "ex0")
out (by-id "ex0-out")]
(go (loop [q []]
(set-html out (render q))
(recur (-> (conj q (<! c)) (peekn 10))))))
;; proposed change #2, objective: reduce verbosity of loop/recur
(go (while true (<! (timeout 250)) (>! c 1)))
(go (while true (<! (timeout 1000)) (>! c 2)))
(go (while true (<! (timeout 1500)) (>! c 3)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment