Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- scala> val examplelist = List(1, 2, 3, 4, 5)
- examplelist: List[Int] = List(1, 2, 3, 4, 5)
- scala> examplelist.map(x => List(x*x))
- res1: List[List[Int]] = List(List(1), List(4), List(9), List(16), List(25))
- scala> examplelist.flatMap(x => List(x*x))
- res4: List[Int] = List(1, 4, 9, 16, 25)
Add Comment
Please, Sign In to add comment