Skip to content

@roman /logical.core.clj
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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]
(all
(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
Something went wrong with that request. Please try again.