SequenceSplit

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)

Split at sequences that match a pattern:

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

Insert an expression at the position of the matched sequences:

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

Split into at most 2 sublists:

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

Scope  (6)

Applications  (1)

Properties & Relations  (8)

See Also

SequenceCases  SequenceReplace  SequencePosition  SequenceCount  Split  SplitBy  StringSplit  PatternSequence  Subsequences  SequenceAlignment

Introduced in 2018
(11.3)