Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Comparing Unequal Dictionaries

$
0
0

So after reading about everything I can find on the subject, I am going to throw in the towel and ask.

I have 2 dictionaries “a” and “b”
a = 4-element Array{Pair{Union{Missing, Int16},Int64},1}:
133 => 2
135 => 9
137 => 1
143 => 4

b = 6-element Array{Pair{Union{Missing, Int16},Int64},1}:
129 => 10
131 => 9
133 => 8
135 => 14
137 => 2
141 => 1

what I want to do is get the difference between the values in each key

the code I have so far is

for (index,value) in a
for (indexj,valuej) in b
if index==indexj
difference= abs(value-valuej)
end
end
end

However, because the Dictionaries are of unequal size, I cannot get the numbers for 129 and 141 in “b” and 143 in “a” because there isn’t a match in both sets. How do I get these values included in the sum of differences?

5 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles