How to resolve the algorithm The Twelve Days of Christmas step by step in the Common Lisp 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 Common Lisp 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 Common Lisp programming language

Source code in the common programming language

let
  ((gifts '("A partridge in a pear tree." "Two turtle doves, and"
            "Three French hens,"          "Four calling birds,"
            "Five gold 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 day from 1 to 12 doing
     (format t "On the ~:r day of Christmas, my true love sent to me:~%" day)
     (loop for gift from (1- day) downto 0 doing
        (format t "~a~%" (nth gift gifts)))
     (format t "~%")))


  

You may also check:How to resolve the algorithm Loops/Nested step by step in the Maple programming language
You may also check:How to resolve the algorithm Number names step by step in the PureBasic programming language
You may also check:How to resolve the algorithm Write entire file step by step in the F# programming language
You may also check:How to resolve the algorithm Copy a string step by step in the Groovy programming language
You may also check:How to resolve the algorithm Read a configuration file step by step in the Nim programming language