This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

" should be a lambda expression" error?

5 posts · 3615 views

(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))))))
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?

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?

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?

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?

Brainfart
:?