Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Usage of clojure.core.logic
(ns logical.core
(:use [clojure.core.logic
:only [
defrel fact fresh to-stream unify all
(defrel man p)
(fact man "adam")
(fact man "peter")
(fact man "paul")
(defrel woman p)
(fact woman "marry")
(fact woman "eve")
(defrel parent p c)
(fact parent "adam" "peter")
(fact parent "eve" "peter")
(fact parent "adam" "paul")
(fact parent "marry" "paul")
(defn father [f c]
(parent f c)
(man f)))
; (use 'logical.core)
; (use '[clojure.core.logic :rename { == unify }])
; (run* [q] (fresh [f c] (father f c) (unify q f)))
; -> (adam, adam)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment