Listについて

Listの操作いろいろ

object Example010 extends Application {
  val l = List("one","two","three")
  println(l(1))  //two
  println(l.count(e => e.length==3))  //2 文字数が3の要素数
  println(l.exists(e => e=="three"))  //true 要素にthreeがあるかどうか
  println(l.filter(e => e.length==3)) //List(one, two)
  println(l.reverse)                  //List(three, two, one)
  println(l.map(e => "["+e+"]"))      //List([one], [two], [three])
}