How to resolve the algorithm Last Friday of each month step by step in the zkl programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Last Friday of each month step by step in the zkl programming language

Table of Contents

Problem Statement

Write a program or a script that returns the date of the last Fridays of each month of a given year. The year may be given through any simple input method in your language (command line, std in, etc).

Example of an expected output:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Last Friday of each month step by step in the zkl programming language

Source code in the zkl programming language

var [const] D=Time.Date;
fcn lastDay(y,d){
   [1..12].pump(List,'wrap(m){  // 12 months, closure for y & d
      [D.daysInMonth(y,m)..1,-1].pump(Void,'wrap(_d){  // work backwards
         D.weekDay(y,m,_d) :
         if (_==d) return(Void.Stop,D.toYMDString(y,m,_d))
      })
   })
}
lastDay(2012,D.Friday).concat("\n").println();

  

You may also check:How to resolve the algorithm Compile-time calculation step by step in the Oberon-2 programming language
You may also check:How to resolve the algorithm Sparkline in unicode step by step in the OCaml programming language
You may also check:How to resolve the algorithm Power set step by step in the Standard ML programming language
You may also check:How to resolve the algorithm Compiler/lexical analyzer step by step in the Python programming language
You may also check:How to resolve the algorithm Rot-13 step by step in the Zoea programming language