On 08/03/2018 04:26 PM, Brian Milby via use-livecode wrote:
"symmetric difference" will get you the first part (unique keys)
Nice. One-stop shopping.
You could shorten the compare loop by using "intersect" (to get common keys) function getKeys pLeft, pRight local tIntersect, tResult intersect pLeft with pRight into tIntersect repeat for each key tKey in tIntersect if pLeft[tKey] is not pRight[tKey] then delete variable pRight[tKey] end if end repeat symmetric difference pLeft with pRight into tResult return the keys of tResult end getKeys
I think Richard was aiming for (if I can put words in his mouth here) the set of just the elements with duplicate keys but different values. Here's my take on that, returning an array with two subarrays:
function getKeys pLeft, pRight local tIntersect, tResult intersect pLeft with pRight into tIntersect repeat for each key tKey in tIntersect if pLeft[tKey] is pRight[tKey] then delete variable pRight[tKey] end if end repeat put tIntersect into tResult["left"] intersect pRight with tIntersect into tResult["right"] return tResult end getKeys -- Mark Wieder ahsoftw...@gmail.com _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode