@Test public void curry() throws Exception { Function2<String, String, String> f2 = (a1, a2) -> a1 + a2; Function3<String, String, String, String> f3 = (a1, a2, a3) -> a1 + a2 + a3; Function4<String, String, String, String, String> f4 = (a1, a2, a3, a4) -> a1 + a2 + a3 + a4; Function5<String, String, String, String, String, String> f5 = (a1, a2, a3, a4, a5) -> a1 + a2 + a3 + a4 + a5; Function6<String, String, String, String, String, String, String> f6 = (a1, a2, a3, a4, a5, a6) -> a1 + a2 + a3 + a4 + a5 + a6; Function7<String, String, String, String, String, String, String, String> f7 = (a1, a2, a3, a4, a5, a6, a7) -> a1 + a2 + a3 + a4 + a5 + a6 + a7; Function8<String, String, String, String, String, String, String, String, String> f8 = (a1, a2, a3, a4, a5, a6, a7, a8) -> a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8; Function9<String, String, String, String, String, String, String, String, String, String> f9 = (a1, a2, a3, a4, a5, a6, a7, a8, a9) -> a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9; assertEquals(f2.invoke(TestData.s1, TestData.s2), Functions.curry(f2) .invoke(TestData.s1) .invoke(TestData.s2)); assertEquals(f3.invoke(TestData.s1, TestData.s2, TestData.s3), Functions.curry(f3) .invoke(TestData.s1) .invoke(TestData.s2) .invoke(TestData.s3)); assertEquals(f4.invoke(TestData.s1, TestData.s2, TestData.s3, TestData.s4), Functions.curry(f4) .invoke(TestData.s1) .invoke(TestData.s2) .invoke(TestData.s3) .invoke(TestData.s4)); assertEquals(f5.invoke(TestData.s1, TestData.s2, TestData.s3, TestData.s4, TestData.s5), Functions.curry(f5) .invoke(TestData.s1) .invoke(TestData.s2) .invoke(TestData.s3) .invoke(TestData.s4) .invoke(TestData.s5)); assertEquals(f6.invoke(TestData.s1, TestData.s2, TestData.s3, TestData.s4, TestData.s5, TestData.s6), Functions.curry(f6) .invoke(TestData.s1) .invoke(TestData.s2) .invoke(TestData.s3) .invoke(TestData.s4) .invoke(TestData.s5) .invoke(TestData.s6)); assertEquals(f7.invoke(TestData.s1, TestData.s2, TestData.s3, TestData.s4, TestData.s5, TestData.s6, TestData.s7), Functions.curry(f7) .invoke(TestData.s1) .invoke(TestData.s2) .invoke(TestData.s3) .invoke(TestData.s4) .invoke(TestData.s5) .invoke(TestData.s6) .invoke(TestData.s7)); assertEquals(f8.invoke(TestData.s1, TestData.s2, TestData.s3, TestData.s4, TestData.s5, TestData.s6, TestData.s7, TestData.s8), Functions.curry(f8) .invoke(TestData.s1) .invoke(TestData.s2) .invoke(TestData.s3) .invoke(TestData.s4) .invoke(TestData.s5) .invoke(TestData.s6) .invoke(TestData.s7) .invoke(TestData.s8)); assertEquals(f9.invoke(TestData.s1, TestData.s2, TestData.s3, TestData.s4, TestData.s5, TestData.s6, TestData.s7, TestData.s8, TestData.s9), Functions.curry(f9) .invoke(TestData.s1) .invoke(TestData.s2) .invoke(TestData.s3) .invoke(TestData.s4) .invoke(TestData.s5) .invoke(TestData.s6) .invoke(TestData.s7) .invoke(TestData.s8) .invoke(TestData.s9)); }
public static <T1, T2, R> Function1<T1, Function1<T2, R>> curry( final Function2< ? super T1, ? super T2, ? extends R> f) { return t1 -> t2 -> f.invoke(t1, t2); }
Functions extends ToolClass { public static <T1, T2, R> Function1<T1, Function1<T2, R>> curry( final Function2< ? super T1, ? super T2, ? extends R> f) { return t1 -> t2 -> f.invoke(t1, t2); } }
Functions extends ToolClass { public static <T1, T2, R> Function1<T1, Function1<T2, R>> curry( final Function2< ? super T1, ? super T2, ? extends R> f) { return t1 -> t2 -> f.invoke(t1, t2); }  }
Functions extends ToolClass { public static <T1, T2, R> Function1<T1, Function1<T2, R>> curry( final Function2< ? super T1, ? super T2, ? extends R> f) { return t1 -> t2 -> f.invoke(t1, t2); }  static Function1<T1, Function1<T2, R>> curry(
            final Function2<
                    ? super T1,
                    ? super T2, ? extends R> f); static Function1<T1,
            Function1<T2,
                    Function1<T3, R>>> curry(
            final Function3<
                    ? super T1,
                    ? super T2,
                    ? super T3, ? extends R> f); static Function1<T1,
            Function1<T2,
                    Function1<T3,
                            Function1<T4, R>>>> curry(
            final Function4<
                    ? super T1,
                    ? super T2,
                    ? super T3,
                    ? super T4,
                    ? extends R> f); static Function1<T1,
            Function1<T2,
                    Function1<T3,
                            Function1<T4,
                                    Function1<T5, R>>>>> curry(
            final Function5<? super T1,
                    ? super T2,
                    ? super T3, ? super T4, ? super T5,
                    ? extends R> f); static Function1<T1,
            Function1<T2,
                    Function1<T3,
                            Function1<T4,
                                    Function1<T5,
                                            Function1<T6, R>>>>>> curry(
            final Function6<
                    ? super T1,
                    ? super T2,
                    ? super T3,
                    ? super T4,
                    ? super T5,
                    ? super T6,
                    ? extends R> f); static Function1<T1,
            Function1<T2,
                    Function1<T3,
                            Function1<T4,
                                    Function1<T5,
                                            Function1<T6, Function1<T7, R>>>>>>> curry(
            final Function7<
                    ? super T1,
                    ? super T2,
                    ? super T3,
                    ? super T4,
                    ? super T5,
                    ? super T6,
                    ? super T7,
                    ? extends R> f); static Function1<T1,
            Function1<T2,
                    Function1<T3,
                            Function1<T4,
                                    Function1<T5,
                                            Function1<T6,
                                                    Function1<T7, Function1<T8, R>>>>>>>> curry(
            final Function8<
                    ? super T1,
                    ? super T2,
                    ? super T3,
                    ? super T4,
                    ? super T5,
                    ? super T6,
                    ? super T7,
                    ? super T8,
                    ? extends R> f); static Function1<T1,
            Function1<T2,
                    Function1<T3,
                            Function1<T4,
                                    Function1<T5,
                                            Function1<T6,
                                                    Function1<T7, Function1<T8,
                                                            Function1<T9, R>>>>>>>>> curry(
            final Function9<
                    ? super T1,
                    ? super T2,
                    ? super T3,
                    ? super T4,
                    ? super T5,
                    ? super T6,
                    ? super T7,
                    ? super T8,
                    ? super T9,
                    ? extends R> f); }
Functions extends ToolClass { public static <T1, T2, R> Function1<T1, Function1<T2, R>> curry( final Function2< ? super T1, ? super T2, ? extends R> f) { return t1 -> t2 -> f.invoke(t1, t2); }  static Function1<T1, Function1<T2, R>> curry(
            final Function2<
                    ? super T1,
                    ? super T2, ? extends R> f); static Function1<T1,
            Function1<T2,
                    Function1<T3, R>>> curry(
            final Function3<
                    ? super T1,
                    ? super T2,
                    ? super T3, ? extends R> f); static Function1<T1,
            Function1<T2,
                    Function1<T3,
                            Function1<T4, R>>>> curry(
            final Function4<
                    ? super T1,
                    ? super T2,
                    ? super T3,
                    ? super T4,
                    ? extends R> f); static Function1<T1,
            Function1<T2,
                    Function1<T3,
                            Function1<T4,
                                    Function1<T5, R>>>>> curry(
            final Function5<? super T1,
                    ? super T2,
                    ? super T3, ? super T4, ? super T5,
                    ? extends R> f); static Function1<T1,
            Function1<T2,
                    Function1<T3,
                            Function1<T4,
                                    Function1<T5,
                                            Function1<T6, R>>>>>> curry(
            final Function6<
                    ? super T1,
                    ? super T2,
                    ? super T3,
                    ? super T4,
                    ? super T5,
                    ? super T6,
                    ? extends R> f); static Function1<T1,
            Function1<T2,
                    Function1<T3,
                            Function1<T4,
                                    Function1<T5,
                                            Function1<T6, Function1<T7, R>>>>>>> curry(
            final Function7<
                    ? super T1,
                    ? super T2,
                    ? super T3,
                    ? super T4,
                    ? super T5,
                    ? super T6,
                    ? super T7,
                    ? extends R> f); static Function1<T1,
            Function1<T2,
                    Function1<T3,
                            Function1<T4,
                                    Function1<T5,
                                            Function1<T6,
                                                    Function1<T7, Function1<T8, R>>>>>>>> curry(
            final Function8<
                    ? super T1,
                    ? super T2,
                    ? super T3,
                    ? super T4,
                    ? super T5,
                    ? super T6,
                    ? super T7,
                    ? super T8,
                    ? extends R> f); static Function1<T1,
            Function1<T2,
                    Function1<T3,
                            Function1<T4,
                                    Function1<T5,
                                            Function1<T6,
                                                    Function1<T7, Function1<T8,
                                                            Function1<T9, R>>>>>>>>> curry(
            final Function9<
                    ? super T1,
                    ? super T2,
                    ? super T3,
                    ? super T4,
                    ? super T5,
                    ? super T6,
                    ? super T7,
                    ? super T8,
                    ? super T9,
                    ? extends R> f);  }