Skip to content

Instantly share code, notes, and snippets.

@furquanuddin94
Created November 25, 2020 10:14
Show Gist options
  • Save furquanuddin94/3c3a0385d6986ec7ae4f18eb6542341b to your computer and use it in GitHub Desktop.
Save furquanuddin94/3c3a0385d6986ec7ae4f18eb6542341b to your computer and use it in GitHub Desktop.
//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