Skip to content

Instantly share code, notes, and snippets.

@patbeagan1
Last active July 12, 2021 19:04
Show Gist options
  • Save patbeagan1/b293048084617a1071d73baa33166e06 to your computer and use it in GitHub Desktop.
Save patbeagan1/b293048084617a1071d73baa33166e06 to your computer and use it in GitHub Desktop.
fun <A, B, R> ((A, B)->R).curry(a: A): (B)->R = { b: B -> this(a, b) }
fun <A, R> ((A)->R).curry(t: A): ()->R = { this(t) }
//----------------------------------------------------------------------
fun f(i: Int, s: String) {
print(i)
println(s)
}
fun main() {
f(1, "test")
// 1test
val b = ::f.curry(2)
b("hi_from_b")
// 2hi_from_b
val c = b.curry("hi_from_c")
c()
// 2hi_from_c
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment