I'm having trouble wrapping my head around how to mix clojure and core.logic.
For example say I have the following problem:
I have a list of key value pairs with attached scores:
(:foo "10" 2)
(:bar "20" 3)
(:baz "30" 7)
And I also have a map:
{:foo "10",
:bar "42",
:baz "30"}
What I'd like to do, is return a list of scores based on the list of scores evaluated in terms of the map.
Using core logic I can do something like this:
(defrel score key value score)
(fact score :foo "10" 2)
(fact score :bar "20" 3)
(fact score :baz "30" 7)
(run* [q]
(conde
((score :foo "10" q))
((score :baz "30" q))))
And I get the intended result:
(2 7)
My problem is I don't see how to turn this into something that I can run in a larger program dynamically. Meaning that I will have different maps and different constraints to apply at different times. I think I can create the argument to conde by writing a function that takes the map and outputs the constraints, but how do I have that run* evaluate in the context of a set of temporary facts?
I could certainly write a function to return what I want without core.logic, but that seems less elegant. Maybe I'm barking up the wrong tree (I'm new to both Clojure and core.logic) and this isn't a constraint problem at all.
So my question are:
How do you mix in core logic when you're pulling your facts and constraints from a sources you won't know until runtime?
And related, how do you do so in an evironment where you want to evaluate a set of constraints within a new environment of facts?