title: Goal ordering in Clojure's `core.logic`
body: <p><a href="https://gist.github.com/4525736" rel="noreferrer">The following Clojure code</a> uses <code>core.logic</code> to solve the same logic problem with the same goals in two different orders.  This choice of ordering causes one to finish quickly and the other to hang.  </p>
  
  <pre><code>(use `clojure.core.logic)
  
  ;; Runs quickly.  Prints (1 2 3).
  (clojure.pprint/pprint (run* [q] (fresh [x] (== x [1,2,3]) 
                                              (membero q x))))
  
  ;; Hangs
  (clojure.pprint/pprint (run* [q] (fresh [x] (membero q x) 
                                              (== x [1,2,3]))))
  </code></pre>
  
  <p>Is there a general solution or common practice to avoid this problem?</p>