Skip to content

Instantly share code, notes, and snippets.

Created January 3, 2017 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/5548ee6fb4aabb9b67aa37c0a0985cdc to your computer and use it in GitHub Desktop.
Save anonymous/5548ee6fb4aabb9b67aa37c0a0985cdc to your computer and use it in GitHub Desktop.
Scala Kata shared content
import com.scalakata._
@instrument class Playground {
// help
def partial1[A, B, C](a: A, f: (A, B) => C): B => C =
b => f(a, b)
def curry[A, B, C](f: (A, B) => C): A => B => C =
a => b => f(a, b)
def uncurry[A, B, C](f: A => B => C): (A, B) => C =
(a, b) => f(a)(b)
def compose[A, B, C](f: B => C, g: A => B): A => C =
(a) => f(g(a))
def sum(a: Int, b: Int): Int = a + b
val curriedSum = curry(sum)
curriedSum(1)(2)
val uncurriedSum = uncurry(curriedSum)
uncurriedSum(1, 2)
def intToFloat(i: Int): Float = i.toFloat
def floatToString(f: Float): String = f.toString
val intAsFloatToString = compose(floatToString, intToFloat)
intAsFloatToString(1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment