Dmi, thanks for your hints!
(I still have problems to think "lispy" the right way, old horse and new tricks etc.)
Taken your code and optimized for more speed:
Code: Select all
(define (show-tree dir)
  (let (files '())
   (dolist (nde (directory dir))
    (if (and (directory? (append dir "/" nde)) (!= nde ".") (!= nde ".."))
     (set 'files (append files (show-tree (append dir "/" nde))))
     (push (append dir "/" nde) files -1)))files))
PS: reverse seems not to be cheap! ;-)
Taken my code with your ideas is similar fast but more flexibel:
Code: Select all
(define (filestree fpath fpattern intflag pathbool)
 (let (retlst '())
 (dolist (nde (directory fpath))
   (if (and (directory? (append fpath "/" nde)) (!= nde ".") (!= nde ".."))
     (setq retlst (append retlst (filestree (append fpath "/" nde) fpattern intflag pathbool)))
     (if (and (!= nde ".") (!= nde ".."))
       (if (regex fpattern nde intflag)
         (if pathbool
           (push (append fpath "/" nde) retlst -1)
           (push nde retlst -1))))))retlst))
My list does not contain "." and ".."
The regex only matches on the filename (not the path)
Path-return is optional.
The regex flag is passed through.