I noticed that in these two years, no-one had gone ahead an written a Haskell version of the task. So I went ahead and did it. Code below.
I had to learn a bit about Haskell date and calendar handling, looping, monads, and comprehensions before succeeding. But RosettaCode and #haskell
were both good sports.
I've optimized for clarity. The isFriday
condition doesn't need to be pulled out into its own function, but I felt it helped readability a bit.
import Data.Time.Calendar
import Data.Time.Calendar.WeekDate
isFriday :: Day -> Bool
isFriday date = weekDay == 5
where (_, _, weekDay) = toWeekDate date
friday13ths :: [Day]
friday13ths =
[ date | year <- [2012..2017]
, month <- [1..12]
, let date = fromGregorian year month 13
, isFriday date ]
main :: IO ()
main = mapM_ print friday13ths