A .pos( x )

Description:

Get the positions of sequence members in another sequence.

Syntax:

A.pos(x)

Note:

x is a sequence. The function returns integer sequence p which satisfies A(p)==x, and returns null if it cannot find the positions for all members of x.

Parameters:

A

A sequence

x

A sequence

Options:

@i

Return a monitonically increasing integer sequence p which satisfies A(p)==x

@c

Return the position in which sequence x first appears in A. By doing so, the position of sub-sequence x in sequence A can be located. If x is not the sub-sequence of A, then return null.

@b

Use the binary search to query the location. In this case A is by default assumed as an ordered sequence. Both Increasing and decreasing are applicable

Return value:

A monotonically increasing integer sequence or an integer sequence

Example:

[6,2,1,4,6,3,7,8].pos@i([1,4,6])

[3,4,5], which is a monitonically increasing integer sequence

[6,2,1,4,6,3,7,8].posi([1,4,6])

[3,4,1], which is an integer sequence

[1,2,3,4,6,7,8].pos@b([3,1,4,6])

[3,1,4,5]

[2,1,4,6,3,7,8].pos@i([8,4,6])

null

[2,1,4,6,3,7,8,4,6,1].pos@c([4,6])

[3]

Related functions:

A.pos()

A.psort()