Support bodyless rules with the defrule! macro
This commit is contained in:
parent
caefce5e0d
commit
3b410d4ba7
@ -42,11 +42,14 @@
|
||||
"Adds a new rule to the database."
|
||||
(db/add-rule db (query-syntax-process rule)))
|
||||
|
||||
(defmacro defrule! [db conclusion body]
|
||||
(defmacro defrule!
|
||||
"Convenience macro to add a new rule to the database.
|
||||
|
||||
Usage example:
|
||||
(defrule [grandparent ?x ?y]
|
||||
(and [parent ?x ?z]
|
||||
[parent ?z ?y]))"
|
||||
`(add-rule! ~db (quote [~conclusion ~body])))
|
||||
([db conclusion]
|
||||
`(add-rule! ~db (quote [~conclusion])))
|
||||
([db conclusion body]
|
||||
`(add-rule! ~db (quote [~conclusion ~body]))))
|
||||
|
Loading…
Reference in New Issue
Block a user