Hello all, I have something like this [:A :B] [:A :C] [:B :C]
how can I get the result [:A [:B :C]], is that possible with core.logic?
What exactly are you asking? Are you asking how to transform the results of your core.logic query? Or are you asking how to rewrite your core.logic query? (in which we’d need a query)
If it’s the former, this might get you started:
user> (reduce (fn [m [k v]] (update-in m [k] #(conj (or % #{}) v))) {} [[:A :B] [:A :C] [:B :C]]) {:A #{:B :C}, :B #{:C}}
No time to make that cleaner, but it’s something to work from
user> (for [[k v] *1] [k (vec v)])
([:A [:B :C]] [:B [:C]])
if you need to get it back to vectors, I guess
Hi, is there a way to use core.logic as a kind of backward chaining rule engine? I kind of figured out that I can write a goal to encapsulate the singe execution of a rule, but how could I express that a portion of goal could be used multiple times to derive a conclusion?
@norman well, I´m trying to use it like I used to use in Prolog as I remember
repetition ([X|T]) :- repetition(X,A), repetition(X,B), A != B.
I don´t know if it´s correctbut that´s the idea
Sorry - i don’t understand what you want.
🙂 ok, I´m trying to use core.logic instead of using something like http://www.clara-rules.org/