struct can't be accessed inside loop?

Discussion of Common Lisp

struct can't be accessed inside loop?

Postby yougene » Fri Feb 12, 2010 7:39 am

Why am I getting this error from running "contains":
"EVAL: undefined function MOVE-X"?

Code: Select all
(defstruct move state previous f g h)

(defun contains (list x)
           (let ((found nil))
             (loop for y in list when (equal (move-x state) (move-y state)) return y)))


TEST CODE
Code: Select all
(setf x (make-move :state '(1 2 3 4 - 5 6 7 8) :f 2 :g 0 :h 2))

(contains (cons (cons x nil) nil) x)
yougene
 
Posts: 23
Joined: Thu Jan 21, 2010 1:23 pm

Re: struct can't be accessed inside loop?

Postby Ramarren » Fri Feb 12, 2010 7:44 am

yougene wrote:Why am I getting this error from running "contains":
"EVAL: undefined function MOVE-X"?


Because the function MOVE-X is undefined. Your structure doesn't have X or Y fields.
Ramarren
 
Posts: 613
Joined: Sun Jun 29, 2008 4:02 am
Location: Warsaw, Poland

Re: struct can't be accessed inside loop?

Postby yougene » Fri Feb 12, 2010 7:48 am

You're right, and I'm in the wrong section(lisp). Mods, feel free to move or delete.
yougene
 
Posts: 23
Joined: Thu Jan 21, 2010 1:23 pm


Return to Common Lisp

Who is online

Users browsing this forum: Google [Bot] and 5 guests

cron