import java.util.concurrent.Callable;
class CurryCallable {
    public static void main(String[] args) {
        Function<Integer,Function<Integer,Integer>> add = new Function<Integer,Function<Integer,Integer>>() {
            protected Function<Integer,Integer> callMe() {
                final Integer first = this.arg();
                return new Function<Integer,Integer>(){
                    private Integer curry = first;
                    protected Integer callMe() {
                        return this.arg() + curry;
                    }
                };
            }
        };
        try {

            System.out.println(add.call(21).call(21));

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

            Callable<Integer> callableAdd = add.call(37).bind(1300);
            System.out.println(callableAdd.call());

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