From 3b410d4ba72e4322615b9ecf32cd8f2468964eb6 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Sat, 20 Jul 2019 16:12:50 -0400 Subject: [PATCH] Support bodyless rules with the defrule! macro --- src/sicp_logic/core.clj | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sicp_logic/core.clj b/src/sicp_logic/core.clj index ff2c511..f67fa7d 100644 --- a/src/sicp_logic/core.clj +++ b/src/sicp_logic/core.clj @@ -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]))))