Thursday, November 10, 2016

Programming in Scala 16/

1.
List(1, 2, 3) creates the list1 :: (2 :: (3 :: Nil)).
2.
List(List(1, 2), List(3), List(), List(4, 5)).flatten
The zip operation takes two lists and forms a list of pairs
3.
The operation xs map f takes as operands a list xs of type List[T] and a function f of type T => U. It
returns the list that results from applying the function f to each list element in xs. For instance:
scala> List(1, 2, 3) map (_ + 1)
res32: List[Int] = List(2, 3, 4)


No comments:

Post a Comment