Skip to content

Instantly share code, notes, and snippets.

@gorsuch
Last active December 12, 2015 06:08
Show Gist options
  • Save gorsuch/4726919 to your computer and use it in GitHub Desktop.
Save gorsuch/4726919 to your computer and use it in GitHub Desktop.
some clojure queue business
(def q (atom '()))
(defn qpush! [queue value]
(swap! queue conj value))
(defn qpop! [queue]
(let [q @queue
v (first q)
nq (pop q)]
(if (compare-and-set! queue q nq) v (recur queue))))
(defn clear [queue]
(swap! queue (fn [x] '())))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment