!752 static PersistentMap cache; p { cache = new PersistentMap("cache"); } answer { if "spell *" exceptionToUser { S n = m.unq(0); if (isInteger(n)) { S val = cache.get(n); if (val != null) ret val; S html = loadPage("https://www.ego4u.com/en/cram-up/vocabulary/numbers/generator?param=" + n + "&show=Show"); L tok = htmlcoarsetok(html); int i = 0; while (i < l(tok) && !tok.get(i).startsWith("cardinal number ")) i += 2; i = indexOf(tok, "
  • ", i); if (i >= 0) { val = tok.get(i+1); cache.put(n, val); ret val; } } } if "fill spell numbers cache *" { int max = min(m.psi(0), 1000), made = 0; for (int i = 0; i < max; i++) if (cache.get(str(i)) == null) { askSelf("spell " + i); ++made; } ret "OK, made numbers up to " + max + " (" + made + " new). Cache size now: " + cache.size(); } }