Skip to content

Instantly share code, notes, and snippets.

@prassee
Created July 15, 2012 10:17
Show Gist options
  • Save prassee/3116179 to your computer and use it in GitHub Desktop.
Save prassee/3116179 to your computer and use it in GitHub Desktop.
Curried Functions in Scala
package scagex
object CurriedFilter {
private val strList = List("scala is asdf","scalaxia is beta","akka is wonderful","sbt is build tools","some text which is not related to skala")
def yieldFilteredItems(filtFn: String => Boolean) = strList.filter(filtFn)
def dofilter(name: String)(filter: String) = filter.contains(name)
def main(args: Array[String]) {
yieldFilteredItems(dofilter("scala")).foreach(println _)
yieldFilteredItems(dofilter("sbt")).foreach(println _)
}
/***
* OUTPUT
* ======
* scala is asdf
* scalaxia is beta
* sbt is build tools
* */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment