Pattern matching is very useful when writing recursive functions. Recursive functions work very well on Haskell: it was designed for them. Here's an example of a recursive function in Haskell
```haskell
factorial 0 = 1
factorial n = n * factorial (n-1)
```
As you can see, pattern matching makes it very easy to set the base case for a recursive function. Here's another recursive function. This one reverses a list. I've called my function reverse' to distinguish it from the existing Haskell reverse function,
```haskell
reverse' [] = []
reverse' (x:xs) = reverse(xs)++[x]
```
There are two important things to note here: First, pattern matching is used to ensure the case of an empty list is handled. Second, note the use of the (x:xs) pattern to identify the head and the tail of the list. Haskell programmers use this pattern a lot.
# Exercise
- [[Haskell Recursion Problems]]