遍历嵌套语言的Julia-lang [英] Traverse nested Dict in Julia-lang

查看:84
本文介绍了遍历嵌套语言的Julia-lang的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Julia中遍历嵌套的Dict时,会出现此错误:

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

已连接,如果a = [0,1] b = [0,1],则可以正常工作.

It's wired, if a = [0,1] b = [0,1], it works fine.

----更新-----

----Update-----

实际上,只要数组b具有11个不同的元素,就会发生该错误. 另外,如果

Actually, as long as array b has 11 distinct elements, the error would happen. Also, if

d[k1][k2] = d[k1][k2] / s

成为

d[k1][k2] = d[k1][k2] * s

或其他任何操作,错误消失.

or any other operations, the error disappear.

有什么想法吗?

推荐答案

此问题现已在development分支中修复,并且在更新后的预发行版本中将可用.

This issue has now been fixed in the development branch, and will be available in the prerelease editions as soon as they gets updated.

请参阅: https://github.com/JuliaLang/julia/pull/5894/文件

这篇关于遍历嵌套语言的Julia-lang的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆