[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cse471 project1



From: Monika <monika.s@asu.edu>
Subject: cse471 project1
Date: Sat, 15 Sep 2001 20:06:38 -0700 (MST)
Message-ID: <Pine.GSO.4.21.0109151956140.7632-100000@general3.asu.edu>

monika.s> Hi,
monika.s> 
monika.s> I have a few questions about A* search algorithm in project 1. What exactly is
monika.s> supposed to be in the parameter list for the A* search? 
monika.s> It wouldn't seem right if these were actual functions, since they would be
monika.s> evaluated each time the A* is called, plus they would require some parameters
monika.s> themselves.

monika.s> 
monika.s> Are they just strings with function names? That still doesn't make
monika.s> sense, since function names are hard coded inside the A* function.
monika.s> 

You _can_ pass functions as part of the call and they will be used
with funcall at the appropriate place.

Consider the following function which takes functional arguments


USER(1): (defun apply-fn-to-list (fn list)
                 (funcall fn list))
APPLY-FN-TO-LIST
USER(2): (setq m '(1 2 3))
(1 2 3)
USER(3): (apply-fn-to-list 'car m)
1
USER(4): (apply-fn-to-list 'cdr m)
(2 3)
USER(5): (apply-fn-to-list 'reverse m)
(3 2 1)
USER(7): (apply-fn-to-list j m)
(3)

monika.s> next question:
monika.s> Is it alright, if I change the parameters of A* slightly, say by supplying a
monika.s> goal state?

You should be able to try and keep the code flexible so that goal
state is checked by a goaltest function rather than a specific state
datastructre. 

monika.s> 
monika.s> And my last question: If "equalp" works for comparring arrays, does one still
monika.s> have to write the equality function, as mentioned towards the end of project
monika.s> 1 description?

Equalp would work. Eq and Eql however don't check content
equality--most people try to use eq and eql and that doesn't
work.. see the example below. (In general the equality between states
is a problem specific concept and you may have to supply your own code 
to check equality. Here, you are right, equalp seems to work jsut
fine).

USER(11): (setq a1 (make-array '(2 2) :initial-contents '((1 2)(3 4)))
)
#2A((1 2) (3 4))
USER(12): (setq a2 (make-array '(2 2) :initial-contents '((1 2)(3
4)))))
#2A((1 2) (3 4))
USER(13): (setq a11 a1)
#2A((1 2) (3 4))
USER(14): (eq a11 a1)
T
USER(15): (eq a1 a2)
NIL
USER(16): (eql a1 a2)
NIL
USER(17): (equalp a1 a11)
T
USER(18): (equalp a1 a2)
T

;;eq and eql check for pointer level equality--ie. two things are
;;considered equal only if they are pointing to the same
;;location. equalp seems to support content level equality--even if
;;the pointers are different the two arrays can still have same
;;contents. 


monika.s> 
monika.s> thanks,
monika.s> Monika
monika.s> 
monika.s> 
monika.s>