Hmm. Could be tricky to make this fast in Lil.
In general, using queries is much more efficient than loops. You can slightly simplify
where (on f x do "r" in x end)@value
as
where value like "*r*"
and you could hoist that "in" out of the loop, since it accepts a list as a left argument. Together, these ideas can make the query much more concise:
on strip x do "" fuse "r" drop x end still:select word:value wod:strip@value where (strip@value) in words where value like "*r*" from words
...but probably not much faster.
You can also avoid stripping the r's twice by using a "subquery"
still:select where wod in words from select word:value wod:strip@value where value like "*r*" from words