!7 sclass Improver { O guesser; // func(A) -> B new HashMap examples; new HashSet errorExamples; new O error; B get(A a) { if (errorExamples.contains(a)) fail(); if (examples.containsKey(a)) ret examples.get(a); try { B b = (B) callF(guesser, a); examples.put(a, b); ret b; } catch e { errorExamples.add(a); throw rethrow(e); } } void addExample(A a, B b) { examples.put(a, b); errorExamples.remove(a); } } p { new Improver i; print("hello => " + i.get("hello")); i.addExample("hello", "world"); print("hello => " + i.get("hello")); }