1
module String (trim, substitute)
4
import Data.Char (isSpace)
5
import Data.List (isPrefixOf)
7
trim :: String -> String
8
trim s = reverse $ ltrim $ reverse $ ltrim s
9
where ltrim s2 = dropWhile isSpace s2
11
substitute :: String -> String -> String -> String
12
substitute _ _ [ ] = []
13
substitute from to xs@(a:as) =
15
then to ++ substitute from to (drop (length from) xs)
16
else a : substitute from to as