The map function takes a function $f$ and a list $xs$, and applies $f$ to each element of $xs$, returning a new list with the results.
Using foldr, we can define map as follows:
```
map' :: (a -> b) -> [a] -> [b]
map' f xs = foldr (\x acc -> f x : acc) []
Show more…