Created
January 23, 2009 14:45
-
-
Save robertpfeiffer/51030 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
(defn cartp | |
"cartesian product" | |
([] ()) | |
([coll] (map list coll)) | |
([coll & rest] (for [x coll y (apply cartp rest)] (conj y x)))) | |
(defn closure-under? | |
[op vals check] | |
(every? (fn [[a b]] (check (op a b))) (cartp vals vals))) | |
(defn a-associative? | |
[op example-vals] | |
(every? (fn [[a b c]] (= (op a (op b c)) (op (op a b) c))) | |
(cartp example-vals example-vals example-vals))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment