Question: I wanted to write a Haskell function that takes a string, and replaces any space characters with the special code %20. For example:

```
sanitize "http://cs.edu/my homepage/I love spaces.html"
-- "http://cs.edu/my%20homepage/I%20love%20spaces.html"

```

I am thinking to use the concat function, so I can concatenates a list of lists into a plain list.

Answer: 
Using a comprehension also works, as follows,

```
changer :: [Char] -> [Char]
changer xs = [ c | v <- xs , c <- if (v == ' ') then "%20" else [v] ]

```
Another expression of Shanth's pattern-matching approach:

```
sanitize = foldr go []
  where
    go ' ' r = '%':'2':'0':r
    go c   r = c:r

```