It depends on what you want. What should the difference be if one key is not present in both dicts?
Assuming a default value of 0, the result could look something like
difference = sum(values(mergewith( (x,y) -> abs(x-y), a, b)))
Or a bit more verbose so you can better see what is going on could be:
diff = 0
same = intersect(keys(a), keys(b))
for i in same
diff += abs(a[i]-b[i])
end
for i in setdiff(keys(a), same)
diff += a[i]
end
for i in setdiff(keys(b), same)
diff += b[i]
end
I would also like to suggest reading this post: