Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I mean, an array could have worked but I think this is more readable than a clever version would have been.

    main = mapM_ putStrLn $ reverse verses
      where 
        verses = combine <$> enumeratedSlices songLines
        combine (i, s) = "On the %s day of Christmas, my true love gave to me\n%s" % dayNames !! i $ concat s
    enumeratedSlices = zip [0..] . init . tails


Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: