Last active
December 19, 2015 03:48
-
-
Save devijvers/5892294 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 pluso [t1 t2 s] | |
| (fn goal [a] | |
| (let [args (map (partial walk a) [t1 t2 s]) | |
| fresh? (map lvar? args) | |
| ground? (map not fresh?)] | |
| (cond | |
| (= [true true true] ground?) (if (= s (+ t1 t2)) a nil) | |
| (= [true true false] ground?) (unify a s (+ t1 t2)) | |
| (= [true false true] ground?) (unify a t2 (- s t1)) | |
| (= [false true true] ground?) (unify a t1 (- s t2)) | |
| :else a)))) |
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
| (run* [q] | |
| (fresh [a] | |
| (pluso q 4 a) | |
| (== a 7))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment