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
;; Trying to learn the practice of making methods into relations | |
;; by making sure it can be used forward and backwards. This method | |
;; of looking at which variable is bound seems to work under the method | |
;; ordering shown below. However, this doesn't seem to me that it is | |
;; truely relational. | |
;; | |
;; Thoughts? | |
(defn sqrto [x y] | |
"A relationship such that y is the square root of y. |
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
; Logic Code | |
(defn uri-path [design view search path] | |
(logic/!= nil design) | |
(logic/conde | |
[(logic/!= nil view) (logic/== ["_design" design "_view" view] path)])) | |
; Unit test | |
(test/deftest test-path | |
(test/is (= '() | |
(logic/run* [q] (db/uri-path nil "view" "search" q)))) |
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
;; This is #58 from page 14. | |
(run* [r] | |
(fresh [x y z] | |
(conde | |
[(== y x)(fresh [x] (== z x))] | |
[(fresh [x] (== y x) (== z x))] | |
[fail]) | |
(== (cons y (cons z ())) r))) | |
; expected: ((_.0 _.1) (_.0 _.1)) | |
; actual: ((_.0 _.1) (_.0 _.0)) |