The Twelve Days of Christmas: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: added personal tag) |
(→{{header|Terraform}}: Add implementation.) |
||
Line 5,501: | Line 5,501: | ||
</pre> |
</pre> |
||
=={{header|Terraform}}== |
|||
<lang terraform>locals { |
|||
days = [ "first", "second", "third", "fourth", "fifth", "sixth", |
|||
"seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth" ] |
|||
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," |
|||
] |
|||
} |
|||
data "template_file" "days" { |
|||
count = 12 |
|||
template = "On the ${local.days[count.index]} day of Christmas, my true love sent to me:\n${join("\n",[for g in range(count.index+1,0,-1): local.gifts[g - 1]])}" |
|||
} |
|||
output "lyrics" { |
|||
value = join("\n\n",[for t in data.template_file.days: t.rendered]) |
|||
}</lang> |
|||
{{Out}} |
|||
<pre>Apply complete! Resources: 0 added, 0 changed, 0 destroyed. |
|||
Outputs: |
|||
lyrics = <<EOT |
|||
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. |
|||
EOT</pre> |
|||
=={{header|Tcl}}== |
=={{header|Tcl}}== |