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
;; fixed version of 'state' at http://mishadoff.com/blog/clojure-design-patterns/#episode-3-state | |
;; takeaway: if you call 'swap!' twice on the same atom, you are probably making a mistake | |
(def user {:name "Jackie Brown" | |
:balance 0 | |
:subscription? false}) | |
(def ^:const SUBSCRIPTION_COST 30) | |
(defn pay |
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
(ns powerset.core-test | |
(:use (clojure set test))) | |
(defn powerset [s] | |
(apply union | |
#{s} ;the complete set of all s | |
(map (fn [i] (powerset (disj s i))) s))) | |
(deftest test-powerset | |
(is (= #{#{}} |