Skip to content

Instantly share code, notes, and snippets.

@bitops
Created December 24, 2011 13:02
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 bitops/1517299 to your computer and use it in GitHub Desktop.
Save bitops/1517299 to your computer and use it in GitHub Desktop.
My first implementation of a simple accumulator in Clojure.
;; Basic integer accumulator.
(def acc (atom 0))
(defn accu
"Basic implementation of an accumulator. Takes an integer and increments the internal counter by that amount. Returns current counter state."
[n] (swap! acc + n) acc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment