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.

struct can't be accessed inside loop?

3 posts · 4573 views

Why am I getting this error from running "contains":
"EVAL: undefined function MOVE-X"?
(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
(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)

Re: struct can't be accessed inside loop?

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.

Re: struct can't be accessed inside loop?

You're right, and I'm in the wrong section(lisp). Mods, feel free to move or delete.