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:

Find the positions of all contiguous occurrences of b:

Scope  (5)

Find sequences of integers in a list:

Check the result:

Find sequences of words in a list:

Find sequences of elements that match a pattern, here giving twin primes:

Find sequences in the first 10 million digits of Pi:

Find all overlapping sequences in a list:

Options  (2)

Overlaps  (2)

Allow overlaps:

Allow no overlaps:

Allow overlaps starting at different positions:

Allow no overlaps:

Allow all overlaps:

Properties & Relations  (3)

Find the position of a sequence:

Find the actual sequence:

Find the number of cases:

Replace the sequence by an expression:

For lists of characters, SequencePosition is very similar to StringPosition:

SubsetPosition matches the elements of the sequence in any order:

SequencePosition matches the sequence only in the specified order:

Wolfram Research (2015), SequencePosition, Wolfram Language function, https://reference.wolfram.com/language/ref/SequencePosition.html.

Text

Wolfram Research (2015), SequencePosition, Wolfram Language function, https://reference.wolfram.com/language/ref/SequencePosition.html.

CMS

Wolfram Language. 2015. "SequencePosition." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SequencePosition.html.

APA

Wolfram Language. (2015). SequencePosition. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SequencePosition.html

BibTeX

@misc{reference.wolfram_2024_sequenceposition, author="Wolfram Research", title="{SequencePosition}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/SequencePosition.html}", note=[Accessed: 30-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_sequenceposition, organization={Wolfram Research}, title={SequencePosition}, year={2015}, url={https://reference.wolfram.com/language/ref/SequencePosition.html}, note=[Accessed: 30-December-2024 ]}