Discussion of Common Lisp
-
yougene
- Posts: 23
- Joined: Thu Jan 21, 2010 1:23 pm
Post
by yougene » Wed Feb 10, 2010 8:21 pm
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?
-
yougene
- Posts: 23
- Joined: Thu Jan 21, 2010 1:23 pm
Post
by yougene » Wed Feb 10, 2010 8:32 pm
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?
-
ramarren
- Posts: 613
- Joined: Sun Jun 29, 2008 4:02 am
- Location: Warsaw, Poland
-
Contact:
Post
by ramarren » Thu Feb 11, 2010 12:07 am
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.
-
gugamilare
- Posts: 406
- Joined: Sat Mar 07, 2009 6:17 pm
- Location: Brazil
-
Contact:
Post
by gugamilare » Thu Feb 11, 2010 5:25 am
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.
-
yougene
- Posts: 23
- Joined: Thu Jan 21, 2010 1:23 pm
Post
by yougene » Thu Feb 11, 2010 9:50 am
Brainfart
