Skip to content

Instantly share code, notes, and snippets.

@shigemk2 shigemk2/flip.scala
Created Mar 12, 2015

Embed
What would you like to do?
def flip[A, B, C](f: A => B => C)(x: B)(y: A) = f(y)(x)
def append: String => String => String = a => a + _
def sub: Int => Int => Int = a => a - _
val flipped = flip(append)(_)
println(flipped("foo")("bar"))
println(flip(append)("foo")("bar"))
println(flip(sub)(5)(3))
println(flip(sub)(3)(5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.