Page 1 of 1

" should be a lambda expression" error?

Posted: Wed Feb 10, 2010 8:21 pm
by yougene

Code: Select all

(defun manhatten-distance (state)
           (let ((index 0)
                 (total 0)
                 (current 0)
                 (cvalue 0)
                 (rvalue 0))
                 (loop for i from 0 to 8 do
                       ((setf current (nth i state))))))

Code: Select all

SYSTEM::%EXPAND-FORM: (SETF CURRENT (NTH I STATE)) should be a lambda expression
   [Condition of type SYSTEM::SIMPLE-SOURCE-PROGRAM-ERROR]

Why am I getting this error?

Re: " should be a lambda expression" error?

Posted: Wed Feb 10, 2010 8:32 pm
by yougene
I found it. I have one too many parenthesis after do.

The thing is, shouldn't I put the sequence of functions into one s-expression block like let does?

Re: " should be a lambda expression" error?

Posted: Thu Feb 11, 2010 12:07 am
by ramarren
yougene wrote:The thing is, shouldn't I put the sequence of functions into one s-expression block like let does?
What do you mean? LET doesn't put the code to be executed into one s-expression. All parentheses in Lisp are meaningful, you shouldn't be putting them at random. All standard operators have a clearly defined grammar, although the one for LOOP is admittedly really long.

Re: " should be a lambda expression" error?

Posted: Thu Feb 11, 2010 5:25 am
by gugamilare
yougene wrote:The thing is, shouldn't I put the sequence of functions into one s-expression block like let does?
The extra parenthesis in let is only around the variables to be declared, not around the forms to be executed.

Re: " should be a lambda expression" error?

Posted: Thu Feb 11, 2010 9:50 am
by yougene
Brainfart
:?