Created
July 15, 2012 10:17
-
-
Save prassee/3116179 to your computer and use it in GitHub Desktop.
Curried Functions in Scala
This file contains hidden or 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
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