initial installable release
This commit is contained in:
@@ -1,11 +1,11 @@
|
|||||||
(use unify)
|
(import unify :as u)
|
||||||
|
|
||||||
(defn rand-nth [e]
|
(defn rand-nth [e]
|
||||||
(get e (math/floor (* (math/random) (length e)))))
|
(get e (math/floor (* (math/random) (length e)))))
|
||||||
|
|
||||||
(defn unifications [clause facts context]
|
(defn unifications [clause facts context]
|
||||||
(if (> (length clause) 0)
|
(if (> (length clause) 0)
|
||||||
(let [bindings (keep |(unify (first clause) $ context) facts)]
|
(let [bindings (keep |(u/unify (first clause) $ context) facts)]
|
||||||
(mapcat |(unifications (slice clause 1) facts $) bindings))
|
(mapcat |(unifications (slice clause 1) facts $) bindings))
|
||||||
[context]))
|
[context]))
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
(selection-strategy possibilities)))
|
(selection-strategy possibilities)))
|
||||||
|
|
||||||
(defn apply-rule [rule facts context]
|
(defn apply-rule [rule facts context]
|
||||||
(let [new-facts (map |(apply-subst context $) (rule :consequent))]
|
(let [new-facts (map |(u/apply-subst context $) (rule :consequent))]
|
||||||
(union new-facts facts)))
|
(union new-facts facts)))
|
||||||
|
|
||||||
(defn step [rules facts]
|
(defn step [rules facts]
|
||||||
|
@@ -3,7 +3,8 @@
|
|||||||
:author "Veit Heller"
|
:author "Veit Heller"
|
||||||
:license "WTFPL"
|
:license "WTFPL"
|
||||||
:url "https://github.com/hellerve/kanon"
|
:url "https://github.com/hellerve/kanon"
|
||||||
:repo "git+https://github.com/hellerve/kanon.git")
|
:repo "git+https://github.com/hellerve/kanon.git"
|
||||||
|
:dependencies ["https://github.com/andrewchambers/janet-unify"])
|
||||||
|
|
||||||
(declare-source
|
(declare-source
|
||||||
:name "kanon"
|
:name "kanon"
|
||||||
|
Reference in New Issue
Block a user