Tuesday, October 6, 2009

P03 - P05: Find nth element, length, reverse a list

scala> val list = List(1,2,3,4,5)
list: List[Int] = List(1, 2, 3, 4, 5)

scala> list(4)
res0: Int = 5

scala> list.length
res1: Int = 5

scala> list.reverse

scala> list.reverse
res2: List[Int] = List(5, 4, 3, 2, 1)

No comments:

Post a Comment

Sociable