let rec sum xs =
match xs with
| [] -> 0
| x :: xs' -> x + sum xs'
def sum(xs: List[Int]): Int = {
xs match {
// if there is an element, add it to the sum of the tail
case x :: tail => x + sum(tail)
// if there are no elements, then the sum is 0
case Nil => 0
}
}