
abstract class Function<A,R> {
    public abstract R call(final A arg);
}

class Curry {
    public static void main(String[] args) {
        Function<Integer,Function<Integer,Integer>> add = new Function<Integer,Function<Integer,Integer>>(){
            public Function<Integer,Integer> call(final Integer a) {
                return new Function<Integer,Integer>(){
                    public Integer call(final Integer b) {
                        return a + b;
                    }
                };
            }
        };
        try {
            System.out.println(add.call(21).call(21));

            Function<Integer,Integer> partialAdd = add.call(21);
            System.out.println(partialAdd.call(21));

        } catch (Exception e) { System.exit(1); }
    }
}
