public
Last active

A simple script to demonstrate the unfortunate importance of goal ordering in `core.logic`.

  • Download Gist
goal-ordering-failure.clj
Clojure
1 2 3 4 5 6 7 8 9
(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]))))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.