How to resolve the algorithm Walk a directory/Recursively step by step in the CoffeeScript programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Walk a directory/Recursively step by step in the CoffeeScript 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 CoffeeScript programming language
Source code in the coffeescript programming language
fs = require 'fs'
walk = (dir, f_match, f_visit) ->
_walk = (dir) ->
fns = fs.readdirSync dir
for fn in fns
fn = dir + '/' + fn
if f_match fn
f_visit fn
if fs.statSync(fn).isDirectory()
_walk fn
_walk(dir)
dir = '..'
matcher = (fn) -> fn.match /\.coffee/
action = console.log
walk dir, matcher, action
You may also check:How to resolve the algorithm Hash from two arrays step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Magic squares of odd order step by step in the VTL-2 programming language
You may also check:How to resolve the algorithm Extend your language step by step in the C programming language
You may also check:How to resolve the algorithm Get system command output step by step in the Wren programming language
You may also check:How to resolve the algorithm JortSort step by step in the PARI/GP programming language