ArrayUnion (open)

Combines the unique values from two arrays into one array

Syntax

LOADLIB "wh::util/algorithms.whlib";

VARIANT FUNCTION ArrayUnion(VARIANT first, VARIANT second)

Parameters

VARIANT first

The first array to use in the union

VARIANT second

The second array to use in the union

Return value

VARIANT

A sorted array containing the combined entries from both arrays

Description

Combines the unique values from two arrays into one array (of the same type) into one array. (The result is NOT guaranteed to be sorted)

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 ['alpha', 'bar', 'baz', 'beta', 'charlie', 'delta', 'echo', 'foo', 'foxtrot', 'golf', 'hotel', 'test']
STRING ARRAY matches1 := ArrayUnion(alpha, bravo);

// returns ['alpha', 'alpha1', 'bar', 'bar1', 'baz', 'baz1', 'beta', 'beta1', 'charlie', 'charlie1', 'foo', 'foo1', 'test', 'test1']
STRING ARRAY matches2 := ArrayUnion(alpha, charlie);

// returns ['alpha', 'bar', 'baz', 'beta', 'charlie', 'foo', 'test']
STRING ARRAY matches3 := ArrayUnion(alpha, delta);