terance wrote:I've wote something .It's working, but I'd like to know how to re-write this code without using setq
?
(defun search_room (point labirint)
(cond ((null labirint) nil)
((eql (caar labirint) point) (second (car labirint)))
(t (search_room point (cdr labirint)))))
(setq way '(in))
(defun search_path (labirint)
(setq way (cons (search_room(first way) labirint) way)) ;(push (search_room(first *way-out*) labirint) *way-out*)
(cons (eql (car way) 'out)
(t (reverse way))) ;переварачивает а потом разрушает список way
(search_path labirint))
Very minimal: For your second function, you could transform:
(setq way '(in))
(defun ...)
to
(let ((way '(in)))
(defun ...))
Then use setf instead of setq inside (really no difference; setf will expand to setq here).