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

Source code in the snobol programming language

	DAYS = ARRAY('12')
	DAYS<1> = 'first'
	DAYS<2> = 'second'
	DAYS<3> = 'third'
	DAYS<4> = 'fourth'
	DAYS<5> = 'fifth'
	DAYS<6> = 'sixth'
	DAYS<7> = 'seventh'
	DAYS<8> = 'eighth'
	DAYS<9> = 'ninth'
	DAYS<10> = 'tenth'
	DAYS<11> = 'eleventh'
	DAYS<12> = 'twelfth'

	GIFTS = ARRAY('12')
	GIFTS<1> = 'A partridge in a pear tree.'
	GIFTS<2> = 'Two turtle doves and'
	GIFTS<3> = 'Three French hens,'
	GIFTS<4> = 'Four calling birds,'
	GIFTS<5> = 'Five gold rings,'
	GIFTS<6> = 'Six geese a-laying,'
	GIFTS<7> = 'Seven swans a-swimming,'
	GIFTS<8> = 'Eight maids a-milking,'
	GIFTS<9> = 'Nine ladies dancing,'
	GIFTS<10> = 'Ten lords a-leaping,'
	GIFTS<11> = 'Eleven pipers piping,'
	GIFTS<12> = 'Twelve drummers drumming,'

       DAY = 1
OUTER  LE(DAY,12)            :F(END)
       INTRO = 'On the NTH day of Christmas, my true love sent to me:'
       INTRO 'NTH' = DAYS
       OUTPUT = INTRO
       GIFT = DAY
INNER  GE(GIFT,1)            :F(NEXT)
       OUTPUT = GIFTS
       GIFT = GIFT - 1       :(INNER)
NEXT   OUTPUT = ''
       DAY = DAY + 1         :(OUTER)
END


  

You may also check:How to resolve the algorithm Higher-order functions step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Map range step by step in the Clojure programming language
You may also check:How to resolve the algorithm SEDOLs step by step in the C programming language
You may also check:How to resolve the algorithm 2048 step by step in the R programming language
You may also check:How to resolve the algorithm Honeycombs step by step in the Ada programming language