Created
September 5, 2016 01:44
-
-
Save dsbw/215a52c9b61d85bffa553a4fb009df30 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(ns temp | |
(:refer-clojure :exclude [==]) | |
(:use [clojure.core.logic]) | |
(:use [clojure.core.logic.pldb])) | |
(db-rel parent x y) | |
(db-rel male x) | |
(db-rel female x) | |
(defn child [x y] | |
(parent y x)) | |
(defn son [x y] | |
(all | |
(child x y) | |
(male x))) | |
(def g | |
(db | |
[parent 'Dad 'Junior] | |
[male 'Dad] | |
[male 'Junior])) | |
(with-db g (run* [q] (son 'Junior q))) | |
;;=> (Dad) | |
(defn son2 [x y] | |
(child x y) | |
(male x)) | |
(with-db g (run* [q] (son2 'Junior q))) | |
;;=> (_0) ;;wut? We've got two variables, we've tested them both, where's the fresh coming from and why isn't it binding? | |
(defn son3 [x y] | |
(fresh [z] | |
(child x y) | |
(male x))) | |
(with-db g (run* [q] (son3 'Junior q))) | |
;;=> (Dad) ;;wut? Where did we bind z with anything? What has z to do with the answer? Why can't we take it out, like son2? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment