Add a cap to th number of variables supported
This commit is contained in:
@ -38,6 +38,10 @@
|
|||||||
collect (cons (cons var nil) entry))
|
collect (cons (cons var nil) entry))
|
||||||
finally (return (mapcar 'reverse perms))))
|
finally (return (mapcar 'reverse perms))))
|
||||||
|
|
||||||
|
(defconstant +maximum-variables+ 12
|
||||||
|
"The maximum number of variables allowed when including variables in the table
|
||||||
|
output.")
|
||||||
|
|
||||||
(defun create-truth-table (prop &key (vars (discover-variables prop))
|
(defun create-truth-table (prop &key (vars (discover-variables prop))
|
||||||
(include-intermediate t) (include-vars t))
|
(include-intermediate t) (include-vars t))
|
||||||
"Evaluate PROP with all possible combinations of truth values for its
|
"Evaluate PROP with all possible combinations of truth values for its
|
||||||
@ -49,6 +53,10 @@ if it is excluded, `discover-variables' will be used to generate it."
|
|||||||
((null vars)
|
((null vars)
|
||||||
(list (list (cons prop (eval-proposition prop '())))))
|
(list (list (cons prop (eval-proposition prop '())))))
|
||||||
(t
|
(t
|
||||||
|
(when (> (length vars) +maximum-variables+)
|
||||||
|
(error 'proposition-eval-error
|
||||||
|
:message (format nil "Got ~A variables when the max is ~A"
|
||||||
|
(length vars) +maximum-variables+)))
|
||||||
(loop for perm in (permute-variables vars)
|
(loop for perm in (permute-variables vars)
|
||||||
for (value sub-map) = (multiple-value-list
|
for (value sub-map) = (multiple-value-list
|
||||||
(eval-proposition prop perm))
|
(eval-proposition prop perm))
|
||||||
|
|||||||
Reference in New Issue
Block a user