Skip to content

PositionIndex

Status: Stable

documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

Description

PositionIndex[list]
    Gives <|value -> {positions}|> mapping each distinct
    element to the list of 1-based positions where it occurs. O(n).

Examples

All examples below are verified against the current Mathilda build.

In[1]:= PositionIndex[{a, b, a, c, a, b}]
Out[1]= <|a -> {1, 3, 5}, b -> {2, 6}, c -> {4}|>

Implementation notes

Attributes: Protected.

Implementation status

Stable — documented, exercised by the test suite and/or worked examples, with no known limitations recorded.

References