Saturday 4 June 2016

Haskell: Return true if the first element of list 5


listUtil.hs
checkList :: [Integer] -> Bool
checkList (5:xs) = True
checkList xs = False

*Main> :load listUtil.hs
[1 of 1] Compiling Main             ( listUtil.hs, interpreted )
Ok, modules loaded: Main.
*Main> 
*Main> 
*Main> checkList []
False
*Main> 
*Main> checkList [2, 3]
False
*Main> 
*Main> checkList [5, 2, 3]
True
*Main> 
*Main> checkList [5]
True
*Main> 


Previous                                                 Next                                                 Home

No comments:

Post a Comment