I've been exploring the DictionaryLookup function recently, but as of yet I've been unable to use it effectively in functions. For targeted uses, I could write
to return all 4-letter words with given second letter. More generally, I could write
g[s_,n_] := Select[DictionaryLookup[_ ~~ ToString[s] ~~ __], StringLength[#] == n &]
to return all n-letter words with prescribed second letter. However, I do not see how to generalize this to searching the k-th letter, short of breaking down all words in the dictionary into characters and using something like
h[s_, k_, n_] := Select[DictionaryLookup[__], Characters[#][[k]] == ToString[s] && StringLength[#] == n &]
This seems to run slow, probably because it is not very clever. For example, h[w,2,3] takes .5 seconds to run on my machine, whereas the equivalent
DictionaryLookup[_ ~~ "w" ~~ _]
runs 10x faster. Am I pushing the boundaries of DictionaryLookup by asking for this sort of flexibility?