Created
November 23, 2012 21:21
-
-
Save hugoduncan/4137374 to your computer and use it in GitHub Desktop.
An issue with core.logic prep?
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
(run* [q] | |
(fresh [pattern production guards rule rule-name] | |
(membero | |
{:pattern pattern :production production} | |
[{:pattern (partial-map {:a :clojure.core.logic/not-found :x 1}) | |
:production {:a 1}} | |
{:pattern (partial-map {:a '?a :c :clojure.core.logic/not-found}) | |
:production {:c '(* ?a 2)}}]) | |
(== {:x 1} pattern) | |
(== q production))) | |
=> ({:a 1}) | |
(run* [q] | |
(fresh [pattern production guards rule rule-name] | |
(membero | |
{:pattern pattern :production production} | |
[{:pattern (partial-map (prep {:a :clojure.core.logic/not-found :x 1})) | |
:production {:a 1}} | |
{:pattern (partial-map (prep {:a '?a :c :clojure.core.logic/not-found})) | |
:production {:c '(* ?a 2)}}]) | |
(== {:x 1} pattern) | |
(== q production))) | |
=> ({:a 1} {:c (* ?a 2)}) |
(let [rules
[{:pattern (partial-map (prep {:a :clojure.core.logic/not-found :x 1}))
:production {:a 1}}
{:pattern (partial-map (prep {:a '?a :c :clojure.core.logic/not-found}))
:production {:c '(* ?a 2)}}]]
(run* [q]
(fresh [pattern production guards rule rule-name]
(membero {:pattern pattern :production production} rules)
(== {:x 1} pattern)
(== q production))))
=> ({:a 1} {:c (* ?a 2)})
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The above are identical apart from the use of prep.