How to resolve the algorithm Walk a directory/Non-recursively step by step in the Oz programming language

Published on 12 May 2024 09:40 PM
#Oz

How to resolve the algorithm Walk a directory/Non-recursively step by step in the Oz programming language

Table of Contents

Problem Statement

Walk a given directory and print the names of files matching a given pattern.
(How is "pattern" defined? substring match? DOS pattern? BASH pattern? ZSH pattern? Perl regular expression?)

Note: This task is for non-recursive methods.   These tasks should read a single directory, not an entire directory tree.
Note: Please be careful when running any code presented here.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Walk a directory/Non-recursively step by step in the Oz programming language

Source code in the oz programming language

declare
  [Path] = {Module.link ['x-oz://system/os/Path.ozf']}
  [Regex] = {Module.link ['x-oz://contrib/regex']}

  Files = {Filter {Path.readdir "."} Path.isFile}
  Pattern = ".*\\.oz$"
  MatchingFiles = {Filter Files fun {$ File} {Regex.search Pattern File} \= false end}
in
  {ForAll MatchingFiles System.showInfo}

  

You may also check:How to resolve the algorithm Substitution cipher step by step in the Go programming language
You may also check:How to resolve the algorithm Loops/For step by step in the Clojure programming language
You may also check:How to resolve the algorithm Semordnilap step by step in the Nanoquery programming language
You may also check:How to resolve the algorithm Solve a Holy Knight's tour step by step in the Haskell programming language
You may also check:How to resolve the algorithm IBAN step by step in the Tcl programming language