initial installable release

This commit is contained in:
2020-03-02 11:07:07 +01:00
parent 3b373a6f58
commit 8deda3d11f
2 changed files with 5 additions and 4 deletions

View File

@@ -1,11 +1,11 @@
(use unify)
(import unify :as u)
(defn rand-nth [e]
(get e (math/floor (* (math/random) (length e)))))
(defn unifications [clause facts context]
(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))
[context]))
@@ -20,7 +20,7 @@
(selection-strategy possibilities)))
(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)))
(defn step [rules facts]