Last active
December 15, 2015 07:48
-
-
Save swannodette/5225702 to your computer and use it in GitHub Desktop.
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
(require '[clojure.core.logic.fd :as fd]) | |
(defrel value* v) | |
(facts value* (take 15 (map vector (iterate inc 0)))) | |
;; slow | |
(time | |
(let [vs (lvars 6)] | |
(doall | |
(run 1 [q] | |
(everyg value* vs) | |
(distincto vs) | |
(== q vs))))) | |
;; fast | |
(time | |
(let [vs (lvars 6)] | |
(doall | |
(run 1 [q] | |
(everyg #(fd/in % (fd/interval 0 15)) vs) | |
(fd/distinct vs) | |
(== q vs))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment