Last active
December 11, 2015 01:48
-
-
Save mrocklin/4525736 to your computer and use it in GitHub Desktop.
A simple script to demonstrate the unfortunate importance of goal ordering in `core.logic`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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])))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment