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 (1)

Every input below was run against the current Mathilda build and its output recorded.

Basic examples (1)

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

Implementation notes

Attributes: Protected.

References