-
-
Save jjthrash/91189cc1fea21aa62721 to your computer and use it in GitHub Desktop.
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
(page "index.html") | |
(def multipliers [1 2 4 7 10 15]) | |
(def default-counts [0 0 0 0 0 0]) | |
(defc counts default-counts) | |
(defc= score (reduce + (map * counts multipliers))) | |
(defn increment-counter [idx c] | |
(assoc c idx (inc (get c idx)))) | |
(html | |
(head | |
(link :rel "stylesheet" :type "text/css" :href "css/main.css")) | |
(body | |
(text "total score: ~{score}") | |
(ul | |
(map (fn [idx] | |
(li | |
(button :on-click (fn [x] (swap! counts (partial increment-counter idx))) | |
(let [label (+ idx 1)] | |
(text "~{label}"))) | |
(let [count (cell= (get counts idx))] | |
(text "(~{count})")))) | |
(range (count @counts)))) | |
(p (button :on-click (fn [x] (swap! counts (constantly default-counts))) | |
(text "reset"))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment