Skip to content

Special Array Operations

Kameron Brooks edited this page Dec 26, 2018 · 3 revisions

Special Array Operations

:: Operator

The expression x :: y returns true if the set x is a subset of y

y must be an array or list

x can be an array, list or a single element

This operator assumes that neither set is sorted and performs an O(n) Linear search of set y for each element in x. The lists are assumed to be unsorted. If all elements in set x are found in y then the operation returns true otherwise it is false

Here are some examples:

1 :: [0,1,2];     // true

[0,1] :: [0,1,2]; // true

[1,0] :: [0,1,2]; // true, order does not matter

3 :: [0,1];       // false

[3] :: [0,1];     // false

[0,3] :: [0,1];   // false

!:: Operator

The expression x :: y returns true if the set x is not a subset of y