SequencePosition

SequencePosition[list,sublist]

gives a list of the starting and ending positions at which sublist appears in list.

SequencePosition[list,patt]

gives all positions at which sequences matching patt occur in list.

SequencePosition[list,patt,n]

includes only the first n occurrences of patt.

Details and Options

Examples

open allclose all

Basic Examples  (2)

Find the positions of a sublist in a list:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Find the positions of all contiguous occurrences of b:

In[1]:=
Click for copyable input
Out[1]=

Scope  (5)

Options  (2)

Properties & Relations  (2)

See Also

SequenceCases  SequenceCount  Position  StringPosition  Take  PatternSequence

Introduced in 2015
(10.1)