title: How do you use core.logic in a practical way in a larger Clojure program?
body: <p>I'm having trouble wrapping my head around how to mix clojure and core.logic.</p>
  
  <p>For example say I have the following problem:</p>
  
  <p>I have a list of key value pairs with attached scores:</p>
  
  <pre><code>(:foo "10" 2)
  (:bar "20" 3)
  (:baz "30" 7)
  </code></pre>
  
  <p>And I also have a map:</p>
  
  <pre><code>{:foo "10",
   :bar "42",
   :baz "30"}
  </code></pre>
  
  <p>What I'd like to do, is return a list of scores based on the list of scores evaluated in terms of the map.</p>
  
  <p>Using core logic I can do something like this:</p>
  
  <pre><code>(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))))
  </code></pre>
  
  <p>And I get the intended result:</p>
  
  <pre><code>(2 7)
  </code></pre>
  
  <p>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?</p>
  
  <p>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. </p>
  
  <p>So my question are:</p>
  
  <p>How do you mix in core logic when you're pulling your facts and constraints from a sources you won't know until runtime?</p>
  
  <p>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?</p>