Last active
August 29, 2015 14:18
-
-
Save alexpw/3feaaa97e46243261749 to your computer and use it in GitHub Desktop.
kathy's sandbox poll fn (quick and dirty)
This file contains hidden or 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
(defn poll [] | |
(let [opts (atom {})] | |
(fn [& args] | |
(if (empty? args) | |
(when (seq @opts) | |
(print-table (for [[k v] (reverse (sort-by last @opts))] | |
{:name k :votes v}))) | |
(doseq [arg args | |
:when (or (string? arg) (keyword? arg)) | |
:let [arg (keyword arg)]] | |
(swap! opts | |
#(update-in % [arg] (fnil inc 0)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment