Skip to content

Instantly share code, notes, and snippets.

@gustavofranke
Created February 17, 2017 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gustavofranke/717a68f4db721b152b08859336b47046 to your computer and use it in GitHub Desktop.
Save gustavofranke/717a68f4db721b152b08859336b47046 to your computer and use it in GitHub Desktop.
playing with curryfied functions
val z: Int => Int = _ + 1
val y = z(3)
val x = z
val sum: (Int, Int) => Int = _ + _
val sumCurried: Int => Int => Int = sum.curried
sum(1,2)
sumCurried(1)(2)
val w = sumCurried(1)
w(2)
val a: (Int, Int, Int) => Int = _ + _ + _
a(1,1,1)
val b: Int => (Int => (Int => Int)) = a.curried
b(1)(1)(1)
val c: Int => (Int => Int) = b(1)
c(1)(1)
val d: Int => Int = b(1)(1)
d(1)
val e: Int => Int = c(1)
e(1)
d(1) == e(1)
val f: Int => (Int => Int) = c compose d
f(1)(1)
def g(x: Int): Int => (Int => Int) = c
def h(x: Int): Int => Int = d
val i = c(1).compose(d)
i(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment