sliding

trait Collection[A] {
  def sliding(m: Int, s: Int): Iterator[Collection[A]]
}

sliding computes all the slices of m elements starting every s elements and returns an Iterator to iterate them.