Contents    Page-10    Prev    Next    Page+10    Index   

Lisp Version of Findpath


(defun findpath (dirtree path)
  (if (null dirtree)
      nil                          ; file not found
      (if (consp (first dirtree))  ; directory?
          (if (eq (first path)       ; dir name ==
                  (first (first dirtree)))
              (findpath              ; yes: go in
                (rest (first dirtree)) ; dir contents
                (rest path))           ; pop path
              (findpath              ; no: keep
                (rest dirtree)       ;     looking
                path))
          (if (eq (first path)       ; file name ==
                  (first dirtree))
              (first path)           ; yes: success
              (findpath              ; no: keep
                (rest dirtree)       ;     looking
                path)) ) ) )