Skip to content

Instantly share code, notes, and snippets.

@oreillyross
Last active August 29, 2015 14:07
Show Gist options
  • Save oreillyross/6a8e4ab40801f966d3d7 to your computer and use it in GitHub Desktop.
Save oreillyross/6a8e4ab40801f966d3d7 to your computer and use it in GitHub Desktop.
List Functions in Scala
object ListFunctions extends App {
val nums = List(2,-4,5,6,-3)
// map function
println(nums map (f => f > 0))
// filter function
println(nums filter (f => f > 0))
// filterNot
println(nums filterNot (f => f > 0))
// partition
println(nums partition (f => f > 0))
// takeWhile
println(nums takeWhile (f => f > 0))
// dropWhile
println(nums dropWhile (f => f > 0))
// span
println(nums span (f => f > 0))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment