WOLFRAM

Split[list]

splits list into sublists consisting of runs of identical elements.

Split[list,test]

treats pairs of adjacent elements as identical whenever applying the function test to them yields True.

Details

  • The default function used to test whether elements are identical is SameQ.
  • Split can be used to perform runlength encoding. »

Examples

open allclose all

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

Split at non-identical elements:

Out[31]=31

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

Split into runs of identical values:

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

Split in increasing runs of elements:

Out[1]=1

Decreasing runs of elements:

Out[2]=2

Split based on first elements:

Out[1]=1

Split at jumps:

Out[1]=1

Split so that in each sublist, successive elements are not the same:

Out[1]=1

Split after every occurrence of a:

Out[1]=1

Split before every occurrence of a:

Out[2]=2

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

Group together identical elements:

Out[10]=10

Split by sign:

Out[1]=1

Only split when there is a change from negative to positive sign (rising edge):

Out[2]=2

Only split when there is a change from positive to negative sign (falling edge):

Out[3]=3

Run-length encoding:

Out[1]=1

Group equivalence classes according to an equivalence function:

Out[2]=2

Distribution of lengths of runs of 0s or 1s in the first million bits of :

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

Distribution of lengths of runs of 0s or 1s in one million pseudorandom bits:

Out[3]=3

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

Flatten acts an inverse of Split:

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

Neat Examples  (3)Surprising or curious use cases

Find runs of numbers in base 10 that contain the same number of 1s:

Out[21]=21

Iterated run-length encoding [more info]:

Out[1]=1

Define terms of the look and say sequence [more info]:

Compute the first five terms of the look and say sequence starting with 1:

Out[2]=2

Do the same starting with 3:

Out[3]=3
Wolfram Research (1996), Split, Wolfram Language function, https://reference.wolfram.com/language/ref/Split.html.
Wolfram Research (1996), Split, Wolfram Language function, https://reference.wolfram.com/language/ref/Split.html.

Text

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

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

CMS

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

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

APA

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

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

BibTeX

@misc{reference.wolfram_2025_split, author="Wolfram Research", title="{Split}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/Split.html}", note=[Accessed: 25-April-2025 ]}

@misc{reference.wolfram_2025_split, author="Wolfram Research", title="{Split}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/Split.html}", note=[Accessed: 25-April-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_split, organization={Wolfram Research}, title={Split}, year={1996}, url={https://reference.wolfram.com/language/ref/Split.html}, note=[Accessed: 25-April-2025 ]}

@online{reference.wolfram_2025_split, organization={Wolfram Research}, title={Split}, year={1996}, url={https://reference.wolfram.com/language/ref/Split.html}, note=[Accessed: 25-April-2025 ]}