Created
September 2, 2017 11:54
-
-
Save mssawant/393ce39de779a084563de07d539ba96b 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
prnEqual :: (Eq a) => a -> a -> IO () | |
prnEqual a b = if a == b then print "True" else print "false" | |
prnGt :: (Ord a, Show a, Num a) => a -> a -> IO () | |
prnGt a b | b < 0 = error "Invalid input" | |
prnGt a b = if a > b then print a else print b | |
reverseList :: [a] -> [a] | |
reverList [] = error "List is empty" | |
reverseList l = foldl (\acc x -> x : acc) [] l -- Understand this can be done using | |
-- flip, but wanted to experiment with | |
-- fold. | |
-- Also want to print the input list here, | |
-- need suggestion. | |
main :: IO () | |
main = do | |
prnEqual 1 1 | |
prnGt 2 1 | |
let l = reverseList [1,2,3,4] | |
print l |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reviewed.