How to resolve the algorithm Empty directory step by step in the Nemerle programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Empty directory step by step in the Nemerle programming language

Table of Contents

Problem Statement

Starting with a path to some directory, determine whether the directory is empty. An empty directory contains no files nor subdirectories. With Unix or Windows systems, every directory contains an entry for “.” and almost every directory contains “..” (except for a root directory); an empty directory contains no other entries.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Empty directory step by step in the Nemerle programming language

Source code in the nemerle programming language

using System.IO;
using System.Console;

module EmptyDirectory
{
    IsDirectoryEmpty(dir : string) : bool
    {
        Directory.GetFileSystemEntries(dir).Length == 0
    }
    
    Main(args : array[string]) : void
    {
        foreach (dir in args) {
            when (Directory.Exists(dir)) {
                WriteLine("{0} {1} empty.", dir, if (IsDirectoryEmpty(dir))  "is" else "is not");
            }
        }
    }
}


  

You may also check:How to resolve the algorithm Catamorphism step by step in the PowerShell programming language
You may also check:How to resolve the algorithm Quine step by step in the dc programming language
You may also check:How to resolve the algorithm Binary search step by step in the Forth programming language
You may also check:How to resolve the algorithm Hostname step by step in the BBC BASIC programming language
You may also check:How to resolve the algorithm Entropy/Narcissist step by step in the Java programming language