Skip to content

Instantly share code, notes, and snippets.

@Odomontois
Created February 13, 2013 17:31
Show Gist options
  • Save Odomontois/4946371 to your computer and use it in GitHub Desktop.
Save Odomontois/4946371 to your computer and use it in GitHub Desktop.
val studenten = Map("Otto" -> 10, "Anna" -> 11, "Bill" -> 4, "Stefan" -> 15)
def filteredKeys[K, V](map: Map[K, V])(filter: V => Boolean) = map.filter(pair => filter(pair._2)).keys.mkString(", ")
val filterStudenten = filteredKeys(studenten) _
println("lower than 10: " + filterStudenten(_ < 10))
println("higher than 10: " + filterStudenten(_ > 10))
println("exactly 15: " + filterStudenten( _ == 15))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment