foldRight

trait Collection[A] {
  def foldRight[B](z: B)(op: (A, B) => B): B
}

foldRight applies the binary operator op to each element, going from right to left, and the previous op result. The first time op is applied it’s fed with the initial value z.

On empty collections this function doesn’t apply op and the initial value z is directly returned.