Guest User

Untitled

a guest
Nov 18th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. scala> val examplelist = List(1, 2, 3, 4, 5)
  2. examplelist: List[Int] = List(1, 2, 3, 4, 5)
  3.  
  4.  
  5. scala> examplelist.map(x => List(x*x))
  6. res1: List[List[Int]] = List(List(1), List(4), List(9), List(16), List(25))
  7.  
  8.  
  9. scala> examplelist.flatMap(x => List(x*x))
  10. res4: List[Int] = List(1, 4, 9, 16, 25)
Add Comment
Please, Sign In to add comment