Skip to content

Instantly share code, notes, and snippets.

@britter
Created October 11, 2016 19:14
Show Gist options
  • Save britter/483ff079ac554453577be8949c2617ac to your computer and use it in GitHub Desktop.
Save britter/483ff079ac554453577be8949c2617ac to your computer and use it in GitHub Desktop.
scala> val xs = List(5,-2,4,9)
scala> xs.zip(xs.scanLeft(0)(_+_).tail)
res2: List[(Int, Int)] = List((5,5), (-2,3), (4,7), (9,16))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment