Rubyでのeach_with_indexみたいにインデックス番号付きに変換します。
List(2, 3, 5).zipWithIndex.foreach(t => println(t._2 + ":" + t._1))
for ((d, i) <- List(2, 5, 6).zipWithIndex) {println(i + ":" + d)}
List(7, 3, 1).zipWithIndex.foreach{case (d, i) => println(i + ":" + d)}
条件式に一致する要素を抽出します。
def drop[T](n: Int, l: List[T]): List[T] = l.zipWithIndex.filter(v => (v._2 + 1) % n != 0).map(_._1) }