Fork me on GitHub
#core-logic
<
2017-12-14
>
noprompt15:12:31

@paulocuneo have you signed the contributor agreement?

zignd18:12:36

in core.logic, considering i have a map as a logic variable, is it it possible to compare to the value of a specific keyword? i thought about doing it like this, but it doesn't work:

(logic/run* [q]
(logic/membero q [{:id 1 :name "foo"} {:id 2 :name "bar"} {:id 3 :name "foo"}])
(logic/== (:name q) "foo"))
=> ()
the only solution i found was to compare the logic variable to a map and adding logic variables to the values i don't know
(logic/run* [q x]
(logic/membero q [{:id 1 :name "foo"} {:id 2 :name "bar"} {:id 3 :name "foo"}])
(logic/== q {:id x :name "foo"}))
=> ([{:id 1, :name "foo"} 1] [{:id 3, :name "foo"} 3])

hiredman19:12:18

I use featurec (I think that is the name of the thing)

zignd19:12:15

it works! thanks @hiredman!

zignd19:12:21

(logic/run* [q]
  (logic/membero q [{:id 1 :name "foo"} {:id 2 :name "bar"} {:id 3 :name "foo"}])
  (logic/featurec q {:name "foo"}))
=> ({:id 1, :name "foo"} {:id 3, :name "foo"})

dominicm20:12:07

https://stackoverflow.com/a/14532781 I'm trying to do something similar to this. Except, I want to potentially build the query based on other lvars. I'm not certain this makes sense as a question. How can I get a list of potential candidate values for an lvar at a the point of my query?

dominicm20:12:47

I pretty much just want to know "oh, it's one of these numbers? I'll grab data for them" vs "Could be anything? I'll grab it all" Might be nice to have some assertions in cases where I can only grab it with some constraint.

dominicm20:12:00

That sounds very similar to my actual end goal, so probably a perfect example.

hiredman20:12:11

(or maybe the original that was forked from)