On Tuesday, September 5, 2017 at 1:50:59 PM UTC-5, Russell Mull wrote: > > 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. > > Oh, right. I'm not sure what I was thinking there.
> > >> 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. > > Okay, that makes sense. > 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. > 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 > Unfortunately, fresh doesn't allow anything other than symbols to be created as fresh variables. (run* [q] (fresh [x] (== x q))) obviously returns: (_0) (run* [q] (fresh [:x] (== :x q))) throws: CompilerException java.lang.Exception: Unsupported binding form: :x -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.