From 60c7eac861a34acc1e490eb66a42e059d9fb9955 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Sun, 14 Jul 2019 23:03:29 -0400 Subject: [PATCH] Fix negation (to the broken version of "negation" given in SICP) --- src/sicp_logic/evaluator.clj | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sicp_logic/evaluator.clj b/src/sicp_logic/evaluator.clj index b081b10..06a815a 100644 --- a/src/sicp_logic/evaluator.clj +++ b/src/sicp_logic/evaluator.clj @@ -19,9 +19,11 @@ (disjoin db (rest disjuncts) input-frames)))) (defn negate [db operands input-frames] - (filter + (mapcat (fn [frame] - (empty? (qeval db (first operands) [frame]))) + (if (empty? (qeval db (first operands) [frame])) + [frame] + [])) input-frames)) (defn execute [exp]