Tu tarea en este ejercicio es escribir código que devuelva la letra de la canción «The Twelve Days of Christmas».
«The Twelve Days of Christmas» es un conocido villancico inglés. Cada estrofa de la canción se construye sobre la anterior.
La letra que devuelva tu código debe coincidir exactamente con el texto completo de la canción que se muestra a continuación.
On the first day of Christmas my true love gave to me: a Partridge in a Pear Tree.
On the second day of Christmas my true love gave to me: two Turtle Doves, and a Partridge in a Pear Tree.
On the third day of Christmas my true love gave to me: three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
On the fourth day of Christmas my true love gave to me: four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
On the fifth day of Christmas my true love gave to me: five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
On the sixth day of Christmas my true love gave to me: six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.
On the seventh day of Christmas my true love gave to me: 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.
On the eighth day of Christmas my true love gave to me: 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.
On the ninth day of Christmas my true love gave to me: 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.
On the tenth day of Christmas my true love gave to me: 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.
On the eleventh day of Christmas my true love gave to me: 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.
On the twelfth day of Christmas my true love gave 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.
Tienes que implementar la función recite, que genera la letra de «The Twelve Days of Christmas». Puedes usar la firma proporcionada si no estás seguro de los tipos, pero no dejes que limite tu creatividad.
Este ejercicio trabaja con datos textuales. Por motivos históricos, el tipo String de Haskell es sinónimo de [Char], un array de caracteres. Para tratar los datos textuales de forma más eficiente, se puede usar el tipo Text.
Como ampliación opcional de este ejercicio, puedes
- text a tu lista de dependencias en package.yaml.Data.Text de la siguiente manera:import qualified Data.Text as T
import Data.Text (Text)
recite :: Int -> Int -> [Text] y referirte a los combinadores de Data.Text como, por ejemplo, T.pack.Data.Text.String por Text en TwelveDays.hs, es decir:recite :: Int -> Int -> [Text]
Esta parte es totalmente opcional.
Regístrate en Exercism para aprender y dominar Haskell con 107 ejercicios y mentoría humana real, todo gratis.