Created
November 6, 2014 14:52
-
-
Save eccstartup/e32567836c5369c738c7 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
module Lab3 where | |
----------------------------------------------------------------------------------------------------------------------------- | |
-- LIST COMPREHENSIONS | |
------------------------------------------------------------------------------------------------------------------------------ | |
-- =================================== | |
-- Ex. 0 - 2 | |
-- =================================== | |
evens :: [Integer] -> [Integer] | |
evens = filter even | |
-- =================================== | |
-- Ex. 3 - 4 | |
-- =================================== | |
-- complete the following line with the correct type signature for this function | |
-- squares :: ... | |
squares :: Integer -> [Integer] | |
squares n = map (^2) [1..n] | |
sumSquares :: Integer -> Integer | |
sumSquares n = sum (squares n) | |
-- =================================== | |
-- Ex. 5 - 7 | |
-- =================================== | |
-- complete the following line with the correct type signature for this function | |
-- squares' :: ... | |
squares' :: Integer -> Integer -> [Integer] | |
squares' m n = map (^2) [n+1..n+m] | |
sumSquares' :: Integer -> Integer | |
sumSquares' x = sum . uncurry squares' $ (x, x) | |
-- =================================== | |
-- Ex. 8 | |
-- =================================== | |
coords :: Integer -> Integer -> [(Integer,Integer)] | |
coords m n = [(x,y)|x<-[0..m], y<-[0..n]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment