I’ve just started learning LISP and I’m just getting my head around the logic for it, however I’ve run into an error I can’t find the solution for..I’m sure it’s because I’ve misused a parentheses somewhere or I’ve misused a function in general, but I’ve been staring at it for an hour now and haven’t made any progress!
(defun not-touching (pos player move)
(let (legal? t)
if ((not (eq (member move '(0 1 2 3 4 7 8 11 12 13 14 15)) nil))
(mapcar #'(lambda(x) (if (not (member move x) nil)
(cond ((and (eq (nth (- (position move x) 1) x) nil)
(not (eq (nth (+ (position move x) 1) x) player))) t)
((and (not (eq (nth (- (position move x) 1) x) player))
(not (eq (nth (+ (position move x) 1) x) player))) t)
((and (not (eq (nth (- (position move x) 1) x) player))
(eq (nth (+ (position move x) 1) x) nil)) t)
(t setf legal? nil))
nil)) *outside-lines*))
legal?))
and the error that I’m getting looks like this:
SYSTEM::%EXPAND-FORM: (NOT (EQ (MEMBER MOVE '(0 1 2 3 4 7 8 11 12 13 14 15)) NIL)) should be
a lambda expression
Any help would be much appreciated!
If you want to program, you need to learn the syntax of the programming language.
Consult the Common Lisp Hyperspec for Common Lisp syntax. Each function/macro/special operator/… of Common Lisp is described in the Common Lisp Hyperspec with its syntax.
See the syntax for LET, IF.
LETexpects a list of bindings.IF,SETFis a form. Needs parentheses around it.NOTtakes only one argument.