Libraryless. Click here for Pure Java version (1697L/11K/35K).
!752 static PersistentMap<S, S> 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<S> tok = htmlcoarsetok(html); int i = 0; while (i < l(tok) && !tok.get(i).startsWith("cardinal number ")) i += 2; i = indexOf(tok, "<li>", 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(); } }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment