Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created February 7, 2013 22:59
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 swannodette/4735012 to your computer and use it in GitHub Desktop.
Save swannodette/4735012 to your computer and use it in GitHub Desktop.
(defnc evenc [x]
(even? x))
(defnc div3c [x]
(zero? (mod x 3)))
;; constrain ?a & ?b so that they must both be even and divisible by 3
(u/unify {:when {'#{?a ?b} [evenc div3c]}}
['{:a ?a :b ?b} {:a 6 :b 12}])
;; => {:a 6 :b 12}
(u/unify {:when {'#{?a ?b} [evenc div3c]}}
['{:a ?a :b ?b} {:a 2 :b 6}])
;; => nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment