listUtil.hs
decomposeList :: [a] -> Maybe (a, [a]) decomposeList [] = Nothing decomposeList (x:xs) = Just (x, xs)
*Main> :load listUtil.hs [1 of 1] Compiling Main ( listUtil.hs, interpreted ) Ok, modules loaded: Main. *Main> *Main> decomposeList [] Nothing *Main> *Main> decomposeList [1] Just (1,[]) *Main> *Main> decomposeList [1, 2, 3, 4] Just (1,[2,3,4]) *Main> *Main> decomposeList "" Nothing *Main> *Main> decomposeList "Hare Ram" Just ('H',"are Ram")
No comments:
Post a Comment