lisp - capturing cl-fad:walk-directory output for finding files -
i've wrestled hours i'm trying write find file function similar unix command. long , short of boils down not understanding why can't return proper value cl-fad:walk-directory function list (cl-fad here http://weitz.de/cl-fad/).
i'm trying this:
(cl-fad:walk-directory "/tmp/" #'(lambda (file) (format nil "~a" file))))
but '; no value' repl. below substituting 'format nil'...
(cl-fad:walk-directory "/tmp/" #'(lambda (file) (format t "~a" file)))
prints out files in /tmp/ directory (and below) stdout. haven't been able collect output list.
i've tried below no success.
(loop f in (cl-fad:walk-directory "/tmp/" #'(lambda (file) (format t "~a" file))) collect (list f)))
the walk function doesn't collect return values mapcar, applies. you'll need save output somewhere, perhaps appending global list or stack.
(let (files) (cl-fad:walk-directory "/tmp/" #'(lambda (x) (push (namestring x) files))) files)
note namestring converts path objects filename.
Comments
Post a Comment