Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created March 12, 2015 15:40
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 shigemk2/37a65bef750572ba310c to your computer and use it in GitHub Desktop.
Save shigemk2/37a65bef750572ba310c to your computer and use it in GitHub Desktop.
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