SERMATCH

Purpose:

Returns the indices where values of a source series are found in a target series.

Syntax:

SERMATCH(source, target, unique, sorted)

source

-

A series, the series to process

target

-

A series, the values to search for

unique

-

Optional, an integer. Return first matches only flag.

 

 

 

0:

Return all matches (default)

 

1:

Return first matches only

sorted

-

Optional, an integer. Target is sorted flag.

 

 

 

-1:

Scan target to determine if sorted (default)

 

0:

Target is not sorted

 

1:

Target is sorted

Returns:

A series, the indices of the source series that are found in the target series.

Example:

W1: {1, 2, 3, 4, 2, 3, 1}

W2: {2, 3}

W3: sermatch(w1, w2)

 

W3 == {2, 3, 5, 6} indicating that W1[2], W1[3], W1[5] and W1[6] are found in W2.

Example:

W1: {2, 3}

W2: {1, 2, 3, 4, 2, 3, 1}

W3: sermatch(w1, w2)

W4: sermatch(w1, w2, 1)

 

W3 == {1, 1, 2, 2} indicating that W1[1] and W1[2] each occur twice in W2.

W4 == {1, 2} indicating that W1[1] and W1[2] occur in W2. Only the first matches are returned.

Example:

W1: {2, 3, 0, 1}

W2: 1..100

W3: sermatch(w1, w2, 0, 1)

 

W3 == {1, 2, 4} indicating that W1[1], W1[2] and W1[4] occur once in W2.

 

Because the target is sorted and sorted is TRUE, SERMATCH uses a faster bisection method of searching and does not need to scan the target to determine if it is pre-sorted.

Remarks:

By default, SERMATCH scans the target series to determine if the target is sorted so a faster bisection method of searching can be employed. If the target is known to be in sorted order, ascending or descending, setting the sorted flag to 1 results in a faster computation by skipping the scan phase. Likewise, if the target is known to be unsorted, the scan phase can be skipped by setting the sorted flag to 0.

 

SERMATCH is implemented as a DLL - sermatch.dll.

 

See DELMATCH to delete the values that occur in a target series.

See Also:

< <= > >= == != (Conditional Operators)

DELMATCH

FIND

REMOVE

SORT