Hi, I'm still new to kona so maybe there's something I'm not understanding. I was trying to make an index of which words in a given dictionary can be made from the letters of what other words. I was using the
COMMON.txt set of words found at Project Gutenberg.
The idea was to make a key for each word comprised of the sorted list of letters contained in the word and to make a dictionary matching each key with the words sharing the same key like so:
wds:0: `"/tmp/COMMON.TXT"
idx:{lts:{l@<l:x@*:'=:x}'x;ix:lts[*:'=lts];(ix[<ix];(=lts)[<ix])} wds
l2w:.+(`$'*idx;*|idx)
That works fine. The next step was to sort the keys by length and then update each dictionary entry by appending the list of each of its subkeys. Since I'm going from shortest to longest, I should only need to check keys one letter shorter. The trouble is this wasn't updating the dictionary.
{l2w[`$x],:g@*:'=g:,/{:[@x;();x]}'l2w[`$x@&:'(!#x)!\:~~!#x]}'{i@<#:'i:i@&~7<#:'i:x@&97<_ic',/1#'x} *:idx
I was worried that "each" might be doing some parallelizing and thus missing earlier stages. Can that happen? I tried to work around that possibility with the following:
que:{i@<#:'i:i@&~7<#:'i:x@&97<_ic',/1#'x} *:idx
while[0<#que;{l2w[`$x],:g@*:'=g:,/{:[@x;();x]}'l2w[`$x@&:'(!#x)!\:~~!#x]}*:que;que:1_ que]
If I add output it at least seems to be running sequentially. But neither of these seem to update l2w. But when I run the following from the REPL I do see a change.
w:"abcdekt"
que?w
10835
l2w[`$w]
,17437
{l2w[`$x],:g@*:'=g:,/{:[@x;();x]}'l2w[`$x@&:'(!#x)!\:~~!#x]}w
17437 17439
l2w[`$w]
17437 17439
It even worked when I processed this out of a queue:
w:"abcdekt"
que:,w
l2w[`$w]
,17437
while[0<#que;{l2w[`$x],:g@*:'=g:,/{:[@x;();x]}'l2w[`$x@&:'(!#x)!\:~~!#x]}*:que;que:1_ que]
l2w[`$w]
17437 17439
Demonstrating all of this in one go, I have this:
wds:0: `"/tmp/COMMON.TXT"
idx:{lts:{l@<l:x@*:'=:x}'x;ix:lts[*:'=lts];(ix[<ix];(=lts)[<ix])} wds
l2w:.+(`$'*idx;*|idx)
que:{i@<#:'i:i@&~7<#:'i:x@&97<_ic',/1#'x} *:idx
w:"abcdekt"
que?w
l2w[`$w]
while[0<#que;{l2w[`$x],:g@*:'=g:,/{:[@x;();x]}'l2w[`$x@&:'(!#x)!\:~~!#x]}*:que;que:1_ que]
l2w[`$w]
que:,w
while[0<#que;{l2w[`$x],:g@*:'=g:,/{:[@x;();x]}'l2w[`$x@&:'(!#x)!\:~~!#x]}*:que;que:1_ que]
l2w[`$w]
Which produces the following output after a couple of minutes:
kona \ for help. \\ to exit.
10835
,17437
,17437
17437 17439
Why would it work out of the shorter queue but not the longer one? It's clearly in both. Should I report this as a bug or am I misunderstanding?
Thanks,
-Doug