Traverse nested Dict in Julia-lang
dictionary, julia, traversal
Solution
This issue has now been fixed in the development branch, and will be available in the prerelease editions as soon as they gets updated.
See: https://github.com/JuliaLang/julia/pull/5894/files
Problem
While I traverse a nested Dict in Julia, it gives this Error: ``` ERROR: access to undefined reference in next at dict.jl:567 ``` Here is the code where you can reproduce this error: ``` a = [0,19620,7291,32633,9,32513,42455,10045,31964,42455,11767,54] b = [14318,16405,19,18913,19,8141,18958,12336,7,16588,17358,30] d = Dict() for aa in a for bb in b if ! haskey(d,aa) d[aa]=Dict() end d[aa][bb] = 0.5 end end for k1 in keys(d) s =0.0 for k2 in keys(d[k1]) s+= d[k1][k2] end for k2 in keys(d[k1]) d[k1][k2] = d[k1][k2] / s end end ``` It's wired, if a = [0,1] b = [0,1], it works fine. ----Update----- Actually, as long as array b has 11 distinct elements, the error would happen. Also, if ``` d[k1][k2] = d[k1][k2] / s ``` become ``` d[k1][k2] = d[k1][k2] * s ``` or any other operations, the error disappear. Any ideas ?