So the following is my code in lisp and I am using emacs
(defun eval-var (var state)
(cond (( atom state) nil)
((eql(caar state) var) (cadr (car state)));;(caar state))
((eval-var var (cdr state))) ) )
(defvar *clause* '( (not a) (not b) c))
(defvar *state* '( (a t) (b t) (c t) (d t) ))
(defun eval-clause (clause state)
(let ((d (cond ((if (equal (car clause) 'a) (eval-var (car clause) state) (not(eval-var (cadr (car clause)) state)))) ))
(e (cond ((if (equal (cadr clause) 'b) (eval-var (cadr clause) state) (not(eval-var (cadr (car clause)) state)))) ))
(f (cond ((if (equal (caddr clause) 'c) (eval-var (caddr clause) state) (not(eval-var (caddr (car clause)) state)))) )) )
(if (equal d e) t nil )))
Below is when I tried to run the functions.
* (load "3sat.lisp")
; Loading #P"/Network/Servers/fs.labs.encs/Volumes/raid1/users_a/vetterc7/Desktop/wsu16/cs355/3sat/3sat.lisp".
T
* (eval-clause *clause* *state*)
; Note: Variable F defined but never used.
;
T
* *clause*
((NOT A) (NOT B) C)
* clause
(A (NOT B) C)
* (eval-clause clause *state*)
Type-error in KERNEL::OBJECT-NOT-LIST-ERROR-HANDLER: A is not of type LIST
[Condition of type TYPE-ERROR]
Restarts:
0: [ABORT] Return to Top-Level.
Debug (type H for help)
(CADR 1 A)[:EXTERNAL]
Source: Error finding source:
Error in function DEBUG::GET-FILE-TOP-LEVEL-FORM: Source file no longer exists:
target:code/list.lisp.
0]
I was hoping that someone could help me out and explain why im getting this error and what I need to do to correct it.
condclauses which are only conditions that look like(if (equal (car clause) 'a) (eval-var (car clause) state) (not(eval-var (cadr (car clause)) state)))but without a corresponding value. Did you intend to have(let ((d (if (...?