SpaceRemover.hs
removeSpaces :: String -> String removeSpaces [] = [] removeSpaces (x:xs) | (x == ' ') = removeSpaces xs | otherwise = x : removeSpaces (xs)
Prelude> :load SpaceRemover.hs [1 of 1] Compiling Main ( SpaceRemover.hs, interpreted ) Ok, modules loaded: Main. *Main> *Main> removeSpaces [] "" *Main> removeSpaces "Hello How are you" "HelloHowareyou" *Main> *Main> removeSpaces "Hello How are you " "HelloHowareyou" *Main> removeSpaces " Hello How are you " "HelloHowareyou"
No comments:
Post a Comment