Return the elements from
list except first element.
listUtil.hs
getTail :: [a] -> Maybe [a] getTail [] = Nothing getTail (x:xs) = Just xs
Prelude> :load listutil.hs [1 of 1] Compiling Main ( listutil.hs, interpreted ) Ok, modules loaded: Main. *Main> *Main> getTail [] Nothing *Main> getTail [1, 2, 3] Just [2,3] *Main> getTail [[1, 2, 3], [2, 3], [4, 5], []] Just [[2,3],[4,5],[]] *Main> getTail "Hare Ram" Just "are Ram" *Main>
No comments:
Post a Comment