Split

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)

Generalizations & Extensions  (5)

Split in increasing runs of elements:

Decreasing runs of elements:

Split based on first elements:

Split at jumps:

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

Split after every occurrence of a:

Split before every occurrence of a:

Applications  (5)

Group together identical elements:

Split by sign:

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

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

Run-length encoding:

Group equivalence classes according to an equivalence function:

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

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

Properties & Relations  (1)

Flatten acts an inverse of Split:

Neat Examples  (2)

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

Iterated run-length encoding [more info]:

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.

CMS

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

BibTeX

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

BibLaTeX

@online{reference.wolfram_2024_split, organization={Wolfram Research}, title={Split}, year={1996}, url={https://reference.wolfram.com/language/ref/Split.html}, note=[Accessed: 21-November-2024 ]}