On Mar 23, 2013, at 12:13 AM, Monte Goulding <[email protected]> wrote:
> Hi Folks > > Just checking if there isn't an undocumented inverse of the intersect > command? What I need is a function that can take two multi-dimensional arrays > and return only keys and elements that both don't have in common.. I'm > guessing I need to implement this myself as a recursive function but just > want to make sure before I go ahead seeing as intersect seems to do the exact > opposite of what I want... Hi, Monte. I think what you're looking for is called the "symmetric difference." <http://en.wikipedia.org/wiki/Symmetric_difference> Here's a way to do that in LC. It's simplified from a library I use. function symmetricDifferenceFromArrays pArray1, pArray2 local tArray1, tArray2 put differenceFromArrays( pArray1, pArray2 ) into tArray1 put differenceFromArrays( pArray2, pArray1 ) into tArray2 union tArray1 with tArray2 return tArray1 end symmetricDifferenceFromArrays function differenceFromArrays tArray1, @pArray2 repeat for each key tKey in pArray2 delete variable tArray1[ tKey ] end repeat return tArray1 end set_differenceFromArrays Does that work for you? -- Dick _______________________________________________ use-livecode mailing list [email protected] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
