Last active
May 10, 2018 04:03
-
-
Save rrodseth/e6227bf559d7ff26a410d57be166656a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Function which takes the name of a month ("May") and the number of days in that month (31), | |
-- and returns a list of all the dates in that month (["May 1", ..., "May 31"]). | |
-- using map | |
datesInMonth :: String -> Int -> [String] | |
datesInMonth month days = map (\x -> month ++ " " ++ show x) [1..days] | |
-- using list comprehension | |
datesInMonth2 :: String -> Int -> [String] | |
datesInMonth2 month days = [ month ++ " " ++ show i | i <- [1..days]] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment