Last active
August 29, 2015 14:07
-
-
Save oreillyross/6a8e4ab40801f966d3d7 to your computer and use it in GitHub Desktop.
List Functions in Scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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