Skip to content

Instantly share code, notes, and snippets.

@notyy
Created October 28, 2011 12:48
Show Gist options
  • Save notyy/1322186 to your computer and use it in GitHub Desktop.
Save notyy/1322186 to your computer and use it in GitHub Desktop.
high order function
def mymap[A,B](xs:List[A],f: A => B): List[B] = {
xs.map(f)
}
scala> mymap(List(1,2,3),((_:Int)*2))
res2: List[Int] = List(2, 4, 6)
scala> mymap(List(1,2,3),((_:Int).toString))
res3: List[java.lang.String] = List(1, 2, 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment