package fun; import tuple.Pair; public class Curry extends Fun3,C>,A,B,C> { public C apply (Fun,C> f, A x, B y) { return curry(f, x, y); } /** * Converts a function that takes a Pair argument to a function that * takes two arguments. * @param f The function. * @return A function g such that g(x,y) is the same as f(<x,y>>) */ public static Fun2 curry (Fun,C> f) { return new Curry().apply(f); } public static Fun curry (Fun,C> f, A x) { return new Curry().apply(f, x); } /** * Applies a function that takes a Pair argument to two values. * @param f The function. * @param x The first value. * @param y The second value. * @return f(<x,y>) */ public static C curry (Fun,C> f, A x, B y) { return f.apply(new Pair(x, y)); } }