Name: intersect Type: command Syntax: intersect with [recursively] [into ] Summary: Removes from an if they have no corresponding in another . Introduced: 1.1 OS: mac, windows, linux, ios, android Platforms: desktop, server, mobile Example: local tLeft, tRight put "green" into tLeft["color"] put "left" into tLeft["align"] put "blue" into tRight["color"] put "100" into tRight["width"] intersect tLeft with tRight # RESULT # the keys of tLeft = "colour" # tLeft["colour"] = "green" # tRight unchanged Example: local tLeft, tRight put "a" into tLeft[1][1] put "b" into tLeft[1][2] put "y" into tRight[1][1] intersect tLeft with tRight -- tLeft unchanged intersect tLeft with tRight recursively # RESULT # tLeft[1][1] = "a" # tLeft[1][2] empty # tRight unchanged Example: function ScriptIntersect pLeft, pRight, pRecursive repeat for each key tKey in pLeft if tKey is not among the keys of pRight then delete variable pLeft[tKey] else if pRecursive then put ScriptIntersect(pLeft[tKey], pRight[tKey], true) into pLeft[tKey] end if end repeat return pLeft end ScriptIntersect function EngineIntersect pLeft, pRight, pRecursive if pRecursive then intersect pLeft with pRight recursively else intersect pLeft with pRight end if return pLeft end EngineIntersect -- This function should return true for all inputs. function CheckIntersect pLeft, pRight, pRecursive return ScriptIntersect(pLeft, pRight, pRecursive) is EngineIntersect(pLeft, pRight, pRecursive) end CheckIntersect Parameters: targetArray (array): The value to modify. templateArray (array): The array to intersect with. destinationArray (optional array): A variable to set as the destination instead of mutating Description: Use the to filter out from an according to the contents of another . The recursively adverb controls whether the intersection recurses through nested arrays or not. Each key of is checked to see whether there is a matching in . The of that do not match an of the are removed from . After the is , the of consists of the logical intersection of the of the original and the keys of . The content of individual elements of the does not affect the final result. Only which exist in the , not their content, controls which of are retained and which are removed. If and have the same set of but different content in each , the does not change the value of . If the into clause is used the operation of the commands is the same as the non-into form except that does not have to be a variable, and the result of the operation is placed into rather than mutating . Changes: The `into` clause was added in LiveCode 9. References: split (command), union (command), element (glossary), array (glossary), command (glossary), key (glossary), element (keyword), difference (command), symmetric difference (command) Tags: properties