Jump to content

The Twelve Days of Christmas: Difference between revisions

→‎{{header|Prog8}}: Add implementation.
(→‎{{header|LOLCODE}}: correct order of HAI version and CAN HAS import.)
(→‎{{header|Prog8}}: Add implementation.)
Line 4,764:
A partridge in a pear tree
</pre>
 
=={{header|Prog8}}==
<syntaxhighlight lang="prog8">%zeropage basicsafe
%import textio
 
main {
str[12] ordinals = [ "first", "second", "third", "fourth",
"fifth", "sixth", "seventh", "eighth",
"ninth", "tenth", "eleventh", "twelfth" ]
 
str[12] 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," ]
 
sub print_gifts(ubyte day) {
ubyte i
txt.print("On the ")
txt.print(ordinals[day])
txt.print(" day of Christmas, my true love sent to me:")
txt.nl()
for i in day to 0 step -1 {
txt.print(gifts[i])
txt.nl()
}
}
 
sub start() {
ubyte day
 
txt.lowercase()
for day in 0 to 11 {
txt.nl()
print_gifts(day)
}
}
}</syntaxhighlight>
 
{{Out}}
<pre>On the first day of Christmas, my true love sent to me:
A partridge in a pear tree.
 
On the second day of Christmas, my true love sent to me:
Two turtle doves and
A partridge in a pear tree.
 
[ ... ]
 
On the twelfth day of Christmas, my true love sent to me:
Twelve drummers drumming,
Eleven pipers piping,
Ten lords a-leaping,
Nine ladies dancing,
Eight maids a-milking,
Seven swans a-swimming,
Six geese a-laying,
Five gold rings,
Four calling birds,
Three French hens,
Two turtle doves and
A partridge in a pear tree.</pre>
 
=={{header|Prolog}}==
Line 4,817 ⟶ 4,886:
A partridge in a pear tree.
 
[ ... ]
 
On the twelfth day of Christmas, my true love sent to me:
1,480

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.