The Twelve Days of Christmas: Difference between revisions

m
→‎{{header|Haskell}}: Applied Ormolu
m (→‎{{header|Terraform}}: simplify range use)
m (→‎{{header|Haskell}}: Applied Ormolu)
Line 2,032:
{{trans|F#}}
<lang haskell>gifts :: [String]
gifts = [
[ "And a partridge in a pear tree!",
"Two turtle doves,",
"Three french hens,",
Line 2,044:
"Ten lords a-leaping,",
"Eleven pipers piping,",
"Twelve drummers drumming," ]
]
 
days :: [String]
days = [
[ "first",
"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth",
"second",
"ninth", "tenth", "eleventh", "twelfth" ]
"third",
"fourth",
verseOfTheDay :: Int -> IO ()
"fifth",
"sixth",
"seventh",
"eighth",
"ninth",
"tenth",
"eleventh",
"twelfth"
]
 
verseOfTheDay :: Int -> IO ()
verseOfTheDay day = do
putStrLn ""$
putStrLn $ "On the " ++ days !! day ++ " day of Christmas my true love gave to me... "
mapM_"On putStrLnthe [dayGift" day<> ddays |!! d <- [day, day-1..0]]
putStrLn $ "On the " ++ days !! day ++<> " day of Christmas my true love gave to me... "
putStrLn ""
mapM_ putStrLn where [dayGift 0day _d =| "Ad partridge<- in[day, aday pear-1 tree!".. 0]]
putStrLn ""
dayGift _ gift = gifts !! gift
where
dayGift 0 _ = "A partridge in a pear tree!"
dayGift _ gift = gifts !! gift
 
main :: IO ()
main = mapM_ verseOfTheDay [0 .. 11]</lang>
</lang>
{{out}}
<pre style="font-size:80%">On the first day of Christmas my true love gave to me...
Line 2,163 ⟶ 2,177:
Three french hens,
Two turtle doves,
And a partridge in a pear tree!</pre>
 
</pre>
 
=={{header|Icon}} and {{header|Unicon}}==
9,655

edits