Created
November 25, 2020 10:14
-
-
Save furquanuddin94/3c3a0385d6986ec7ae4f18eb6542341b to your computer and use it in GitHub Desktop.
This file contains 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
//list of integers | |
val myList: List[Int] = List(1, 2, 7, 3, 6, 4) | |
//predicate function to check whether a number is odd or not | |
def isOdd: Int => Boolean = value => value % 2 == 1 | |
//create a new list containing only odd elements | |
myList.filter(isOdd) //output: List(1, 7, 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment