Skip to content

Instantly share code, notes, and snippets.

@swannodette
Last active December 15, 2015 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swannodette/5225702 to your computer and use it in GitHub Desktop.
Save swannodette/5225702 to your computer and use it in GitHub Desktop.
(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