Erlang直方图对2个图求和

jjhzyzn0  于 2022-12-08  发布在  Erlang
关注(0)|答案(1)|浏览(210)

如何在Erlang中创建两个字典的直方图总和?例如,如果您有两个字典:

{a: 1, c: 4, d:7} and {a:5, b:8, d:1}

总和为:

{a:6, b:8, c:4, d:8}
mpgws1up

mpgws1up1#

假设您的指令分别绑定到AB变量,则:

Result = dict:merge(fun (_Key, V1, V2) -> V1 + V2 end, A, B)

相关问题