The Twelve Days of Christmas: Difference between revisions
→{{header|q}}: removed redundant iteration and variable
(→{{header|LOLCODE}}: correct order of HAI version and CAN HAS import.) |
(→{{header|q}}: removed redundant iteration and variable) |
||
(One intermediate revision by one other user not shown) | |||
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:
Line 4,953 ⟶ 5,022:
=={{header|q}}==
<syntaxhighlight lang="q">
" seventh eighth ninth tenth eleventh twelfth"
STANZA:( / final stanza
"On the twelfth day of Christmas";
"My true love gave to me:";
"Twelve drummers drumming";
"Eleven pipers piping";
Line 4,970 ⟶ 5,042:
"")
-1 raze
.[;(::;0);ssr[;"twelfth";];DAYS] / number the verses
STANZA 0 1,/:#\:[;til 15] -2 -til 12; / compose 12 verses
</syntaxhighlight>
{{out}}
Line 5,002 ⟶ 5,074:
And a partridge in a pear tree.
</pre>
* [https://code.kx.com/q/ref/ Language Reference]
=={{header|Quackery}}==
|