ArraysIntersect (open)
Returns TRUE if any value in either supplied array is present in both arrays.
Syntax
LOADLIB "wh::util/algorithms.whlib";
BOOLEAN FUNCTION ArraysIntersect(VARIANT first, VARIANT second)
Parameters
VARIANT first
The first array to use in the comparison
VARIANT second
The second array to use in the comparison
Return value
BOOLEAN
Description
Iterates through every value in the shortest of the supplied array to determine if it is present in the longest array. If a match is found, returns TRUE. If no matches are present, returns FALSE.
Examples
STRING ARRAY alpha := [ "foo", "bar", "baz", "test", "alpha", "beta", "charlie" ];
STRING ARRAY bravo := [ "delta", "echo", "foxtrot", "baz", "bar", "golf", "hotel" ];
STRING ARRAY charlie := [ "foo1", "bar1", "baz1", "test1", "alpha1", "beta1", "charlie1" ];
STRING ARRAY delta := [ "foo", "bar", "baz", "test", "alpha", "beta", "charlie" ];
// returns TRUE
STRING ARRAY matches1 := ArraysIntersect(alpha, bravo);
// returns FALSE
STRING ARRAY matches2 := ArraysIntersect(alpha, charlie);
// returns TRUE
STRING ARRAY matches3 := ArraysIntersect(alpha, delta);