Skip to content

Instantly share code, notes, and snippets.

@netologist
Created March 23, 2013 17:37
Show Gist options
  • Save netologist/5228630 to your computer and use it in GitHub Desktop.
Save netologist/5228630 to your computer and use it in GitHub Desktop.
functional-programming-samples-with-scala

object CurryTest extends Application {

def filter(xs: List[Int], p: Int => Boolean): List[Int] = if (xs.isEmpty) xs else if (p(xs.head)) xs.head :: filter(xs.tail, p) else filter(xs.tail, p)

def modN(n: Int)(x: Int) = ((x % n) == 0)

val nums = List(1, 2, 3, 4, 5, 6, 7, 8) println(filter(nums, modN(2))) println(filter(nums, modN(3))) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment