listUtil.hs
lengthOfList :: [a] -> Integer lengthOfList [] = 0 lengthOfList (x:xs) = 1 + lengthOfList xs
*Main> :load listUtil.hs [1 of 1] Compiling Main ( listUtil.hs, interpreted ) Ok, modules loaded: Main. *Main> *Main> lengthOfList [] 0 *Main> *Main> lengthOfList [2, 3, 5, 7] 4 *Main> *Main> lengthOfList ["Hello", "How", "are", "you"] 4 *Main>
No comments:
Post a Comment