Last active
November 25, 2020 10:17
-
-
Save furquanuddin94/3d7cd80bfe7bf81b51458aec01061c2d 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) | |
//function to multiply an integer by 2 | |
def doubleUpFunction: Int => Int = value => value*2 | |
//creating a new list multiplying each element by 2 | |
myList.map(element => doubleUpFunction(element)) //output: List(2, 4, 14, 6) | |
//or simply | |
myList.map(doubleUpFunction) //output: List(2, 4, 14, 6) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment