You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
I have written some computationally & memory efficient implementations for these already which produce the exact behaviours I demonstrated in the example code already, so I'd be happy to write up a PR if that's desirable.
Sift.Dictionary.difference(dictA, dictB) - Would produce a new dictionary containing values which are different in B than in A. This only considers top-level equality. This is also the inverse of Sift.Dictionary.merge.
Sift.Dictionary.differenceDeep(dictA, dictB) - Would produce a new dictionary containing values which are different in B than in A. Sub-dictionaries would only contain differences as well. This is also the inverse of Sift.Dictionary.mergeDeep.
localkinds= {
Apple=true;
Pear=true;
Others= {
Carrot=true;
Potato=true;
};
}
localdictA= {
Apple=9;
Pear=7;
Others= {
Carrot=11;
Potato=15;
};
Kinds=kinds;
}
localdictB= {
Apple=10;
Pear=7;
Others= {
Carrot=12;
};
Kinds=kinds;
}
-- Shallow difference, only top level equalitySift.Dictionary.difference(dictA, dictB) -- { Apple = 10, Others = { Carrot = 12 } }-- Deep difference, sub-dictionaries will also be deeply diffedSift.Dictionary.differenceDeep(dictA, dictB) -- { Apple = 10, Others = { Carrot = 12, Potato = Sift.None }, Kinds = { } }-- Another valid implementation might omit Kinds since it has no changes. This behaviour might not be expected in some cases though, so it might be worth considering which of the two implementations makes the most sense.-- It might also be good to consider how table equality should be treated. In the example I assume just == behaviour, but `Dictionary.equals` or `Dictionary.equalsDeep` could also be used for diffing sub-dicts.
The text was updated successfully, but these errors were encountered:
I have written some computationally & memory efficient implementations for these already which produce the exact behaviours I demonstrated in the example code already, so I'd be happy to write up a PR if that's desirable.
Sift.Dictionary.difference(dictA, dictB)
- Would produce a new dictionary containing values which are different in B than in A. This only considers top-level equality. This is also the inverse ofSift.Dictionary.merge
.Sift.Dictionary.differenceDeep(dictA, dictB)
- Would produce a new dictionary containing values which are different in B than in A. Sub-dictionaries would only contain differences as well. This is also the inverse ofSift.Dictionary.mergeDeep
.The text was updated successfully, but these errors were encountered: