Skip to content

Instantly share code, notes, and snippets.

@adekunleba
Created November 18, 2018 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adekunleba/3c111a205c5dfd0477bc9ea15a242d75 to your computer and use it in GitHub Desktop.
Save adekunleba/3c111a205c5dfd0477bc9ea15a242d75 to your computer and use it in GitHub Desktop.
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment