The Twelve Days of Christmas: Difference between revisions

→‎{{header|q}}: removed redundant iteration and variable
(→‎{{header|Prog8}}: Add implementation.)
(→‎{{header|q}}: removed redundant iteration and variable)
 
Line 5,022:
=={{header|q}}==
<syntaxhighlight lang="q">
daysDAYS:" "vs"first second third fourth fifth sixth seventh eighth ninth tenth eleventh twelfth",
" seventh eighth ninth tenth eleventh twelfth"
 
STANZA:( / final stanza
gifts:(
"On the twelfth day of Christmas";
"My true love gave to me:";
"Twelve drummers drumming";
"Eleven pipers piping";
Line 5,039 ⟶ 5,042:
"")
 
-1 raze
verses:stanza 0 1,/:{(reverse x)+2+til each 2+x}til 12
lyric:raze .[;0 2;{"A",5_x}5_] verses{@[x;0;ssr[;"twelfth";y]]}'days / tweak one line
.[;(::;0);ssr[;"twelfth";];DAYS] / number the verses
 
STANZA 0 1,/:#\:[;til 15] -2 -til 12; / compose 12 verses
1 "\n"sv lyric; // print
</syntaxhighlight>
{{out}}
Line 5,071 ⟶ 5,074:
And a partridge in a pear tree.
</pre>
* [https://code.kx.com/q/ref/ Language Reference]
* [https://code.kx.com/q/learn/pb/xmas-days/ The Q Playbook: The Twelve Days of Christmas – analysis]
 
=={{header|Quackery}}==
39

edits