I have this Lil code to print a table of 10 English words that remain words when the 'r's are removed from the word:
words:wods:still:0 each w in "" drop "\n" split read["words"] # /usr/share/dict/words"] words[w]:1 if "r" in w wods["" fuse "r" drop w]:w end end each v k in wods if k in words still[v]:k end end show[select word:value wod:wods@value from random[still -10]]
which produces output like
+--------------+---------------+ | word | wod | +--------------+---------------+ | "evaluated" | "revaluated" | | "emigated" | "emigrated" | | "boated" | "borated" | | "estated" | "restated" | | "expatiated" | "expatriated" | | "elatedness" | "relatedness" | | "pedated" | "predated" | | "ungated" | "ungrated" | | "pated" | "prated" | | "gated" | "grated" | +--------------+---------------+
if reading a 'words' file that contains only the 3k words that include "ated", this runs in 11s (lila.awk) or 16s (lilt). So, actually reading /usr/share/dict/words with its half a million words, is pretty infeasible.
Is there a much better way to do this in Lil, or is this sort of batch processing out of scope for Lil?
Oh, I had a second question about selecting from an array using an array of booleans, but I found that 'select' can do that. Which gives this code that runs in 22ms in lilt, instead of 16s:
words:extract value where 5<count@value from "\n" split read["words"] still:select word:value wod:(on f x do "" fuse "r" drop x end)@value where (on f x do ("" fuse "r" drop x) in words end)@value where (on f x do "r" in x end)@value from words show[table random[still -10]]
but this needs 4s to process only 50k words, so the full dictionary's still out.