Olivier Boudry wrote:
Hi all,I'm trying to write a untab function that would split a string on tabs and return a list. Code is here. import Data.List (break, unfoldr) import Data.Char (String) untab :: String -> [String] untab s = unfoldr untab' s untab' :: String -> Maybe (String, String) untab' s | s == "" = Nothing | otherwise = Just (h, ts) where (h, t:ts) = break (== '\t') s This code raises an exception when handling the last portion of the string. Break returns a ("something", "") and t:ts cannot match on "".
untab' [] = Nothing untab' s = Just (h , drop 1 t) where (h,t) = break (== '\t') s _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
