@Test public void curry() throws Exception { Function<String, Function<String, Function<String, Function<String, Function<String, String>>>>> secondVariable = RxCurryingFunction .curry(new Function5<String, String, String, String, String, String>() { @Override public String apply(String first, String second, String third, String fourth, String fifth) { return first + second + third + fourth + fifth; } }); String result = secondVariable.apply("Hello ").apply("This ").apply("Is ").apply("Curried ") .apply("Func"); Assert.assertEquals("Hello This Is Curried Func", result); }
public static <A, B, R> Function<A, Function<B, R>> curry(final BiFunction<A, B, R> func) { return new Function<A, Function<B, R>>() { @Override public Function<B, R> apply(final A a) throws Exception { return new Function<B, R>() { @Override public R apply(final B b) throws Exception { return func.apply(a, b); } }; } }; }
RxCurryingFunction { public static <A, B, R> Function<A, Function<B, R>> curry(final BiFunction<A, B, R> func) { return new Function<A, Function<B, R>>() { @Override public Function<B, R> apply(final A a) throws Exception { return new Function<B, R>() { @Override public R apply(final B b) throws Exception { return func.apply(a, b); } }; } }; } }
RxCurryingFunction { public static <A, B, R> Function<A, Function<B, R>> curry(final BiFunction<A, B, R> func) { return new Function<A, Function<B, R>>() { @Override public Function<B, R> apply(final A a) throws Exception { return new Function<B, R>() { @Override public R apply(final B b) throws Exception { return func.apply(a, b); } }; } }; } private  RxCurryingFunction(); }
RxCurryingFunction { public static <A, B, R> Function<A, Function<B, R>> curry(final BiFunction<A, B, R> func) { return new Function<A, Function<B, R>>() { @Override public Function<B, R> apply(final A a) throws Exception { return new Function<B, R>() { @Override public R apply(final B b) throws Exception { return func.apply(a, b); } }; } }; } private  RxCurryingFunction(); static Function<A, Function<B, R>> curry(final BiFunction<A, B, R> func); static Function<A, Function<B, Function<C, R>>> curry(final Function3<A, B, C, R> func); static Function<A, Function<B, Function<C, Function<D, R>>>> curry(
            final Function4<A, B, C, D, R> func); static Function<A, Function<B, Function<C, Function<D, Function<E, R>>>>> curry(
            final Function5<A, B, C, D, E, R> func); static Function<A, Function<B, Function<C, Function<D, Function<E, Function<F, R>>>>>> curry(
            final Function6<A, B, C, D, E, F, R> func); static Function<A, Function<B, Function<C, Function<D, Function<E, Function<F, Function<G, R>>>>>>> curry(
            final Function7<A, B, C, D, E, F, G, R> func); static Function<A, Function<B, Function<C, Function<D, Function<E, Function<F, Function<G, Function<H, R>>>>>>>> curry(
            final Function8<A, B, C, D, E, F, G, H, R> func); static Function<A, Function<B, Function<C, Function<D, Function<E, Function<F, Function<G, Function<H, Function<I, R>>>>>>>>> curry(
            final Function9<A, B, C, D, E, F, G, H, I, R> func); }
RxCurryingFunction { public static <A, B, R> Function<A, Function<B, R>> curry(final BiFunction<A, B, R> func) { return new Function<A, Function<B, R>>() { @Override public Function<B, R> apply(final A a) throws Exception { return new Function<B, R>() { @Override public R apply(final B b) throws Exception { return func.apply(a, b); } }; } }; } private  RxCurryingFunction(); static Function<A, Function<B, R>> curry(final BiFunction<A, B, R> func); static Function<A, Function<B, Function<C, R>>> curry(final Function3<A, B, C, R> func); static Function<A, Function<B, Function<C, Function<D, R>>>> curry(
            final Function4<A, B, C, D, R> func); static Function<A, Function<B, Function<C, Function<D, Function<E, R>>>>> curry(
            final Function5<A, B, C, D, E, R> func); static Function<A, Function<B, Function<C, Function<D, Function<E, Function<F, R>>>>>> curry(
            final Function6<A, B, C, D, E, F, R> func); static Function<A, Function<B, Function<C, Function<D, Function<E, Function<F, Function<G, R>>>>>>> curry(
            final Function7<A, B, C, D, E, F, G, R> func); static Function<A, Function<B, Function<C, Function<D, Function<E, Function<F, Function<G, Function<H, R>>>>>>>> curry(
            final Function8<A, B, C, D, E, F, G, H, R> func); static Function<A, Function<B, Function<C, Function<D, Function<E, Function<F, Function<G, Function<H, Function<I, R>>>>>>>>> curry(
            final Function9<A, B, C, D, E, F, G, H, I, R> func);  }