Skip to content

Instantly share code, notes, and snippets.

@frenchy64
Created July 9, 2011 18:02
Show Gist options
  • Save frenchy64/1073805 to your computer and use it in GitHub Desktop.
Save frenchy64/1073805 to your computer and use it in GitHub Desktop.
(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