I will probably have lost most people in the above sentence, but for anyone that just knows LISP i just need help with some stupid brackets that are appearing where they shouldnt be!
this is my current code
(defun variable? (term) (if (eq (car term) 'VAR) t (if (eq (car term) 'var) t ()))) (defun abstraction? (term) (if (eq (car term) 'LAMBDA) t (if (eq (car term) 'lambda) t ()))) (defun application? (term) (if (eq (car term) 'APP) t (if (eq (car term) 'app) t ()))) (defun var-symbol (term) (if (variable? term) (cdr term) ())) (defun make-var (term) (cons 'VAR (list term))) (defun abs-var (term) (if (abstraction? term) (cadr term) ())) (defun abs-body (term) (if (abstraction? term) (cddr term) ())) (defun make-abs (term1 term2) (cons 'LAMBDA (cons term1 (list term2)))) (defun app-fn (term) (if (application? term) (car term) ())) (defun app-arg (term) (if (application? term) (cdr term) ())) (defun make-app (term1 term2) (cons 'APP (cons term1 (list term2))))
and we've been told that typing in
(make-abs 'x (make-app (make-var 'x) (make-var 'x)))
should return
(LAMBDA x (APP (VAR x) (VAR x)))
which it does! but then we were told that applying abs-body to it should return
(APP (VAR x) (VAR x))
but i get
((APP (VAR x) (VAR x)))
any ideas?!


Help

MultiQuote














