(def my-other-var '[z]) |
When I run (run* [q] (fresh [x] (== [x] ['z]) (== q x))), I get (z), which makes sense.
When I run (run* [q] (fresh [x] (== q x))), I get (_0), which makes sense since I've placed no restriction on x.
However, when I run (run* [q] (fresh [x] (== ['x] ['z]) (== q x))), I get (), which doesn't make sense to me. Obviously (== ['x] ['z]) is placing some sort of impossible constraint on x, but I can't tell what that constraint is actually doing.
Ultimately, what I want to be able to do is something along the lines of:
(def my-var '[x])
(run* [q] (fresh [x] (== my-var ['z]) (== q x)))
and get back (z) instead of ().
On Monday, September 4, 2017 at 7:49:11 AM UTC-7, Laverne Schrock wrote:When I run (run* [q] (fresh [x] (== [x] ['z]) (== q x))), I get (z), which makes sense.
When I run (run* [q] (fresh [x] (== q x))), I get (_0), which makes sense since I've placed no restriction on x.
However, when I run (run* [q] (fresh [x] (== ['x] ['z]) (== q x))), I get (), which doesn't make sense to me. Obviously (== ['x] ['z]) is placing some sort of impossible constraint on x, but I can't tell what that constraint is actually doing.You're asking it to restrict the results to cases where the vector containing symbol x is unifies with the vector containing symbol z. Symbols unify with equality, and 'x does not equal 'z, so you get no results.
Ultimately, what I want to be able to do is something along the lines of:
(def my-var '[x])
(run* [q] (fresh [x] (== my-var ['z]) (== q x)))
and get back (z) instead of ().That doesn't make a ton of sense; the usage of my-var is evaluated in regular Clojure fashion to be '[x], and it devolves to the same case.
It's not really clear what you're trying to do, so it's hard to offer further advice.
But you might find the whole enterprise a bit less confusing if you use keywords or strings in the places you're using symbols.- Russell
On Tuesday, September 5, 2017 at 1:50:59 PM UTC-5, Russell Mull wrote:It's not really clear what you're trying to do, so it's hard to offer further advice.Essentially, what I'm trying to do is pass expressions dynamically to run*. If I hardcode [x] I'm fine, but if I want to be able to derive the vector from user input, I'm stuck, since I can't seem to figure out how to associate a symbol that I pass in with the fresh variable introduced with fresh.