How to resolve the algorithm The Twelve Days of Christmas step by step in the SETL 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 SETL 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 SETL programming language
Source code in the setl programming language
program christmas;
ordinals := [
"first", "second", "third", "fourth", "fifth",
"sixth", "seventh", "eight", "ninth", "tenth",
"eleventh", "twelfth"
];
verses := [
"A partridge in a pear tree.",
"Two turtle doves and",
"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"
];
loop for i in [1..12] do
print("On the " + ordinals(i) + " day of Christmas,");
print("My true love gave to me");
loop for j in [i, i-1..1] do
print(verses(j));
end loop;
print;
end loop;
end program;
You may also check:How to resolve the algorithm Benford's law step by step in the Stata programming language
You may also check:How to resolve the algorithm 99 bottles of beer step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Active object step by step in the Julia programming language
You may also check:How to resolve the algorithm Matrix transposition step by step in the Picat programming language
You may also check:How to resolve the algorithm Executable library step by step in the Wren programming language