How to resolve the algorithm The Twelve Days of Christmas step by step in the Tailspin programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm The Twelve Days of Christmas step by step in the Tailspin programming language

Table of Contents

Problem Statement

Write a program that outputs the lyrics of the Christmas carol The Twelve Days of Christmas. The lyrics can be found here.
(You must reproduce the words in the correct order, but case, format, and punctuation are left to your discretion.)

Let's start with the solution:

Step by Step solution about How to resolve the algorithm The Twelve Days of Christmas step by step in the Tailspin programming language

Source code in the tailspin programming language

def ordinal: ['first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth', 'eleventh', 'twelfth'];
def gift: [
  'a partridge in a pear tree',
  'two turtle-doves',
  'three French hens',
  'four calling birds',
  'five golden rings',
  'six geese a-laying',
  'seven swans a-swimming',
  'eight maids a-milking',
  'nine ladies dancing',
  'ten lords a-leaping',
  'eleven pipers piping',
  'twelve drummers drumming'
];
templates punctuation
  <=1> '.' !
  <=2> ' and' !
  <=5> ';' !
  <> ',' !
end punctuation

1..12 -> \singVerse(
  'On the $ordinal($); day of Christmas,
my true love gave to me:
' !
  $..1:-1 -> '$gift($);$->punctuation;
' !
'
' !
\singVerse) -> !OUT::write

  

You may also check:How to resolve the algorithm Zumkeller numbers step by step in the Java programming language
You may also check:How to resolve the algorithm Keyboard input/Flush the keyboard buffer step by step in the Go programming language
You may also check:How to resolve the algorithm Loop over multiple arrays simultaneously step by step in the Visual FoxPro programming language
You may also check:How to resolve the algorithm Evolutionary algorithm step by step in the Insitux programming language
You may also check:How to resolve the algorithm Associative array/Creation step by step in the ALGOL 68 programming language