ListUtil.hs
getTails :: [a] -> [[a]] getTails [] = [] getTails list@(x:xs) = (list) : getTails (xs)
*Main> :load listUtil.hs [1 of 1] Compiling Main ( listUtil.hs, interpreted ) Ok, modules loaded: Main. *Main> *Main> getTails "Hello" ["Hello","ello","llo","lo","o"] *Main> *Main> getTails [2, 3, 5, 7] [[2,3,5,7],[3,5,7],[5,7],[7]] *Main> *Main> getTails [True, False, True] [[True,False,True],[False,True],[True]] *Main>
No comments:
Post a Comment