Skip to content

Instantly share code, notes, and snippets.

@robertpfeiffer
Created January 23, 2009 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertpfeiffer/51026 to your computer and use it in GitHub Desktop.
Save robertpfeiffer/51026 to your computer and use it in GitHub Desktop.
(defn monoid?
([op zero example-vals check]
(and (= zero (op zero zero))
(every? (fn [val] (= val (op zero val) (op val zero)))
example-vals)
(closure-under? op example-vals check)
(a-associative? op (conj example-vals zero)))))
(monoid? clojure.set/union #{} [#{:d :g} #{2 3}] set?)
(monoid? concat nil [[:a :b] [1 2 3][""]'(a b c d e)] seq?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment