import java.util.Vector; import java.util.Enumeration; abstract class Closure_OO { abstract Object apply_OO(Object o); } class Closure_1 extends Closure_OO { TestMapVector receiver; String s1; Closure_1(TestMapVector receiver, String s1) { this.receiver = receiver; this.s1 = s1; } Object apply_OO(Object s2) { return receiver.apply_1(s1,s2); } } class MapVector extends Vector { MapVector map(Closure_OO f) { MapVector newMV = new MapVector(); for (Enumeration e = this.elements() ; e.hasMoreElements() ;) { newMV.addElement(f.apply_OO(e.nextElement())); } return newMV; } } public class TestMapVector { Object apply_1(String s1, Object s2) { return (Object)(s1 + (String)s2); } Closure_OO curryConcat(String s1) { return new Closure_1(this,s1); } public static void main(String[] args) { MapVector things = new MapVector(); TestMapVector tester = new TestMapVector(); things.addElement("one"); things.addElement("two"); things.addElement("three"); MapVector mv = things.map(tester.curryConcat("plus ")); System.out.println(mv); } }