(Defun Convert-State-to-String (state) ; recall a state is a list of the form: ; ( (1 2 3) (4 5 6) (7 8 0)) ) here I represent blank as a 0 ; let's convert it to a string (not a number, but a string) ; first we copy the state so we don't destroy it inadvertently..this is "cstate" below ; return-string will be the converted state to a string with a capital S at the beginning (let ( (cstate (append (copy-list (first state)) (copy-list (second state)) (copy-list (third state)) ) ) (returned-string "S" ) ) ;close the let's local variable defs. (loop (if (null cstate) (return returned-string)) (setf returned-string (concatenate 'string returned-string (subseq "012345678" (first cstate) (1+ (first cstate))))) (setf cstate (rest cstate)) );loop ) ;let ) ;defun ;Now that that is done, we want to convert the character representation of the state to ;a symbol...Here we use LISP's intern function for that purpose. (defun Convert-State-to-Symbol (state) (intern (Convert-State-to-String state))) ;now...we'll use LISP's internal hash table to store this symbol, and thus store our ;states for us...and I will use property lists to indicate that the state has been visited. ;an example (setf state '( (7 8 0) (1 2 3) (4 5 6))) (setf (get (Convert-State-to-Symbol state) 'Visited) T) ;later, if I want to know whether I have visited a state before, I do it this way: (if (get (Convert-State-to-Symbol state) 'Visited) (print "indeed I have...") )