WOLFRAM

SequenceSplit[list,patt]

splits list into sublists separated by sequences that match the sequence pattern patt.

SequenceSplit[list,pattrhs]

inserts rhs at the position of each matched sequence.

SequenceSplit[list,{patt1rhs1,}]

inserts rhsi at the position of each patti.

SequenceSplit[list,patt,n]

splits into at most n sublists.

Details

  • SequenceSplit[list,patt] by default gives the list of sublists of list that occur between sequences defined by patt; it does not include the sequences themselves.
  • SequenceSplit[list,{patt1rhs1,,patta,}] includes rhsi at the position of sequences matching patt1 but omits sequences matching patta.

Examples

open allclose all

Basic Examples  (3)Summary of the most common use cases

Split at sequences that match a pattern:

Out[1]=1

Insert an expression at the position of the matched sequences:

Out[1]=1

Split into at most 2 sublists:

Out[1]=1

Scope  (6)Survey of the scope of standard use cases

Use a pattern to split the original list:

Out[1]=1

Use a rule to replace the matched sequences:

Out[1]=1

Split the original list at sequences that match any of the patterns:

Out[1]=1

Use a list of rules to replace the matched sequences:

Out[1]=1

Use rules and patterns:

Out[1]=1

Split into at most 2 sublists:

Out[1]=1

Applications  (1)Sample problems that can be solved with this function

Find the most frequent length for a run of consecutive non-prime numbers:

Out[1]=1

Properties & Relations  (8)Properties of the function, and connections to other functions

Insert a list of elements at the position of the matched sequence:

Out[1]=1

Use Sequence instead of List to splice the elements in the output list:

Out[2]=2

Rules are tried in the given order:

Out[2]=2
Out[3]=3

A list of sublists is considered as a single sequence pattern:

Out[1]=1
Out[2]=2

Use Alternatives to split at any of the sequence subpatterns:

Out[3]=3

The third argument of SequenceSplit is the count of sublists not considering insertions:

Out[1]=1
Out[2]=2
Out[3]=3

Split a list into sublists delimited by sequences that match a pattern:

Out[1]=1

Replace a sequence by an expression:

Out[2]=2

Find the position of the sequence:

Out[3]=3

Find the actual sequence:

Out[4]=4

Count the number of cases:

Out[5]=5

Split at any sequence of integers:

Out[1]=1

Use SequenceCases instead:

Out[2]=2

For lists of characters, SequenceSplit is similar to StringSplit:

Out[2]=2
Out[3]=3

Split by parity:

Out[1]=1

Compare with SplitBy:

Out[2]=2
Wolfram Research (2018), SequenceSplit, Wolfram Language function, https://reference.wolfram.com/language/ref/SequenceSplit.html.
Wolfram Research (2018), SequenceSplit, Wolfram Language function, https://reference.wolfram.com/language/ref/SequenceSplit.html.

Text

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

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

CMS

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

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

APA

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

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

BibTeX

@misc{reference.wolfram_2025_sequencesplit, author="Wolfram Research", title="{SequenceSplit}", year="2018", howpublished="\url{https://reference.wolfram.com/language/ref/SequenceSplit.html}", note=[Accessed: 29-March-2025 ]}

@misc{reference.wolfram_2025_sequencesplit, author="Wolfram Research", title="{SequenceSplit}", year="2018", howpublished="\url{https://reference.wolfram.com/language/ref/SequenceSplit.html}", note=[Accessed: 29-March-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_sequencesplit, organization={Wolfram Research}, title={SequenceSplit}, year={2018}, url={https://reference.wolfram.com/language/ref/SequenceSplit.html}, note=[Accessed: 29-March-2025 ]}

@online{reference.wolfram_2025_sequencesplit, organization={Wolfram Research}, title={SequenceSplit}, year={2018}, url={https://reference.wolfram.com/language/ref/SequenceSplit.html}, note=[Accessed: 29-March-2025 ]}