Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 erlang 中创建两个字典的直方图总和?例如,如果您有 2 个字典:
{a: 1, c: 4, d:7} and {a:5, b:8, d:1}
总和将是:
{a:6, b:8, c:4, d:8}
谢谢
假设您的 dicts 被绑定到A和B变量,那么:
A
B
Result = dict:merge(fun (_Key, V1, V2) -> V1 + V2 end, A, B)