Created
July 9, 2011 18:02
-
-
Save frenchy64/1073805 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
(ns logic-test.core | |
(:refer-clojure :exclude [inc reify ==]) | |
(:use clojure.core.logic.prelude) | |
(:use clojure.core.logic.minikanren)) | |
(defn secondo [l x] | |
(exist [r] | |
(resto l r) | |
(firsto r x))) | |
(defn emit-bash1 [cloj bash] | |
(exist [f r o] | |
(conde | |
((firsto cloj f) | |
(conde | |
((== 'println f) | |
(== "echo " o) | |
(secondo cloj r) | |
(== [o r] bash))))))) | |
(comment | |
;; Can convert Clojure to Bash | |
logic-test.core=> (run* [q] | |
(emit-bash1 '(println "asdf") q)) | |
(["echo " "asdf"]) | |
;; And can go the other way for free | |
logic-test.core=> (run* [q] | |
(emit-bash1 q ["echo " "asdf"])) | |
((println asdf . _.0)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment