Skip to content

Instantly share code, notes, and snippets.

@mssawant
Created September 2, 2017 11:54
Show Gist options
  • Save mssawant/393ce39de779a084563de07d539ba96b to your computer and use it in GitHub Desktop.
Save mssawant/393ce39de779a084563de07d539ba96b to your computer and use it in GitHub Desktop.
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
@vvv
Copy link

vvv commented Sep 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment