Created
December 24, 2011 13:02
-
-
Save bitops/1517299 to your computer and use it in GitHub Desktop.
My first implementation of a simple accumulator in Clojure.
This file contains 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
;; 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