Split
Examples
open all close allBasic Examples (1)
Scope (6)
Split into runs of identical values:
seq = RandomInteger[3, 10]Split[%]Split in increasing runs of elements:
Split[{1, 2, 3, 4, 3, 2, 1, 5, 6, 7, 4, 3}, Less]Split[{1, 2, 3, 4, 3, 2, 1, 5, 6, 7, 4, 3}, Greater]Split based on first elements:
Split[{1 -> a, 1 -> b, 2 -> a, 2 -> c, 3 -> a}, First[#1] === First[#2]&]Split[Array[Prime, 20], #2 - #1 < 4&]Split so that in each sublist, successive elements are not the same:
Split[{a, a, a, b, a, b, b, a, a, a, c, a}, UnsameQ]Split after every occurrence of a:
Split[{a, b, a, b, c, d, a, a}, # =!= a&]Split before every occurrence of a:
Split[{a, b, a, b, c, d, a, a}, #2 =!= a&]Applications (5)
Group together identical elements:
Split[Sort[{a, a, a, b, b, a, a, c, c, c}]]Split[{3, 0, -4, 3, 3, -2, 0, -3, -4, 5}, Sign[#1] == Sign[#2]&]Only split when there is a change from negative to positive sign (rising edge):
Split[{3, 0, -4, 3, 3, -2, 0, -3, -4, 5}, !(Sign[#1] < 0 && Sign[#2] > 0)&]Only split when there is a change from positive to negative sign (falling edge):
Split[{3, 0, -4, 3, 3, -2, 0, -3, -4, 5}, !(Sign[#1] > 0 && Sign[#2] < 0)&]{First[#], Length[#]}& /@ Split[{a, a, a, b, b, a, a, c, c, c}]Group equivalence classes according to an equivalence function:
f = Round;
x = RandomReal[5, 20];Split[SortBy[x, f], f[#1] === f[#2]&]Distribution of lengths of runs of 0s or 1s in the first million bits of
:
Tally[Map[Length, Split[First[RealDigits[π, 2, 10 ^ 6]]]]]ListLogPlot[%]Distribution of lengths of runs of 0s or 1s in one million pseudorandom bits:
ListLogPlot[Tally[Map[Length, Split[RandomInteger[1, 10 ^ 6]]]]]Properties & Relations (1)
Neat Examples (3)
Find runs of numbers in base 10 that contain the same number of 1s:
Split[Table[DigitCount[n, 10, 1], {n, 50}]]Iterated run-length encoding [more info]:
NestList[Flatten[{Length[#], First[#]}& /@ Split[#]]&, {1}, 8]Define terms of the look and say sequence [more info]:
RunLengthEncode[x_List] := Through[{First, Length}[#]]& /@ Split[x]
LookAndSaySequence[n_, d_ : 1] := NestList[Flatten[Reverse /@ RunLengthEncode[#]]&, {d}, n - 1]Compute the first five terms of the look and say sequence starting with 1:
LookAndSaySequence[5]LookAndSaySequence[5, 3]See Also
SplitBy Partition SequenceSplit StringSplit GroupBy FindClusters DeleteAdjacentDuplicates Union Flatten ReplaceList Tally BinLists GapPenalty
Function Repository: SplitAt SplitAtPositions
Tech Notes
Related Guides
History
Introduced in 1996 (3.0)
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_2026_split, author="Wolfram Research", title="{Split}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/Split.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_split, organization={Wolfram Research}, title={Split}, year={1996}, url={https://reference.wolfram.com/language/ref/Split.html}, note=[Accessed: 13-June-2026]}