How to resolve the algorithm Walk a directory/Recursively step by step in the PicoLisp programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Walk a directory/Recursively step by step in the PicoLisp programming language

Table of Contents

Problem Statement

Walk a given directory tree and print files matching a given pattern.

Note: This task is for recursive methods.   These tasks should read an entire directory tree, not a single directory.

Note: Please be careful when running any code examples found here.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Walk a directory/Recursively step by step in the PicoLisp programming language

Source code in the picolisp programming language

(let Dir "."
   (recur (Dir)
      (for F (dir Dir)
         (let Path (pack Dir "/" F)
            (cond
               ((=T (car (info Path)))             # Is a subdirectory?
                  (recurse Path) )                 # Yes: Recurse
               ((match '`(chop "s@.l") (chop F))   # Matches 's*.l'?
                  (println Path) ) ) ) ) ) )       # Yes: Print it

  

You may also check:How to resolve the algorithm Longest common substring step by step in the Quackery programming language
You may also check:How to resolve the algorithm Terminal control/Inverse video step by step in the Perl programming language
You may also check:How to resolve the algorithm CSV to HTML translation step by step in the Nim programming language
You may also check:How to resolve the algorithm Random numbers step by step in the Scala programming language
You may also check:How to resolve the algorithm Greatest element of a list step by step in the FreeBASIC programming language