Created
February 9, 2013 03:02
-
-
Save austinhaas/4743651 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 replo | |
(:refer-clojure :exclude [==]) | |
(:use [clojure.core.logic])) | |
(defn replo | |
"A relation between two sequences in and out, such that out is the | |
same as in, except that all occurences of k have been replaced with | |
v." | |
[k v in out] | |
(matche [in out] | |
[[() ()]] | |
[[(k . d) (v . e)] (replo k v d e)] | |
[[(a . d) (b . e)] | |
(conda | |
[(replo k v a b) (replo k v d e)] | |
[(== a b) (replo k v d e)])])) | |
(run 1 [q] | |
(fresh [k v in out] | |
(== k 'p) | |
(== v 'q) | |
(== in '((p) x)) | |
;;(== out '((q) x)) | |
(replo k v in out) | |
(== q [k v in out]))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment