Tokenize a string: Difference between revisions

Content added Content deleted
Line 164: Line 164:
joinWith :: [a] -> <nowiki>[[a]]</nowiki> -> [a]
joinWith :: [a] -> <nowiki>[[a]]</nowiki> -> [a]
joinWith _ [] = []
joinWith d xs = concat $ List.intersperse d xs
joinWith _ [x] = x
joinWith d (x:xs) = x ++ d ++ joinWith d xs


putStrLn $ joinWith "." $ splitBy (== ',') $ "Hello,How,Are,You,Today"
putStrLn $ joinWith "." $ splitBy (== ',') $ "Hello,How,Are,You,Today"