({{, (RefLink[Split, paclet:ref/Split])[list]
splits list into sublists consisting of runs of identical elements. }, {, (RefLink[Split, paclet:ref/Split])[list,test]
treats pairs of adjacent elements as identical whenever applying the function test to them yields (RefLink[True, paclet:ref/True]). }})

OpenersNotesSection(Spacer1)Details

The default function used to test whether elements are identical is (RefLink[SameQ, paclet:ref/SameQ]).

(RefLink[Split, paclet:ref/Split]) can be used to perform run-length encoding. »

OpenersPrimaryExamplesSection(Spacer1)Examples  (14)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Split[{a,a,a,b,b,a,a,c}]

OpenersExampleSection1(Spacer1)Generalizations & Extensions  (5)

Split in increasing runs of elements:

Split[{1,2,3,4,3,2,1,5,6,7,4,3},Less]

Decreasing runs of elements:

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 at jumps:

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&]

OpenersExampleSection2(Spacer1)Applications  (5)

Group together identical elements:

Split[Sort[{a,a,a,b,b,a,a,c,c,c}]]

Split by sign:

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)&]

Run-length encoding:

{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]]]]]

OpenersExampleSection3(Spacer1)Properties & Relations  (1)

(RefLink[Flatten, paclet:ref/Flatten]) acts an inverse of (RefLink[Split, paclet:ref/Split]):

Split[{a,a,a,b,b,a,a,c,c,c}]

Flatten[%]

OpenersExampleSection4(Spacer1)Neat Examples  (2)

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 (WebLink[[more info], http://www.wolframscience.com/nksonline/page-905e-text]]):

NestList[Flatten[{Length[#],First[#]}&/@Split[#]]&,{1},8]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[SplitBy, paclet:ref/SplitBy])  ▪  (RefLink[Partition, paclet:ref/Partition])  ▪  (RefLink[SequenceSplit, paclet:ref/SequenceSplit])  ▪  (RefLink[StringSplit, paclet:ref/StringSplit])  ▪  (RefLink[GroupBy, paclet:ref/GroupBy])  ▪  (RefLink[FindClusters, paclet:ref/FindClusters])  ▪  (RefLink[Union, paclet:ref/Union])  ▪  (RefLink[Flatten, paclet:ref/Flatten])  ▪  (RefLink[ReplaceList, paclet:ref/ReplaceList])  ▪  (RefLink[Tally, paclet:ref/Tally])  ▪  (RefLink[BinLists, paclet:ref/BinLists])  ▪  (RefLink[GapPenalty, paclet:ref/GapPenalty])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Partitioning and Padding Lists, paclet:tutorial/PartitioningAndPaddingLists])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Rearranging & Restructuring Lists, paclet:guide/RearrangingAndRestructuringLists])}, {▪(RefLinkPlain[List Manipulation, paclet:guide/ListManipulation])}, {▪(RefLinkPlain[Discrete & Integer Data, paclet:guide/DiscreteAndIntegerData])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/30-rearranging-lists.html])(WebLink[: Rearranging Lists, https://www.wolfram.com/language/elementary-introduction/30-rearranging-lists.html])}, {(WebLink[DocumentationFooterIconsRelatedLinks-NKS.png(Spacer1)NKS|Online, http://www.wolframscience.com/nksonline/index/search.cgi?SearchIndex=Split]) ((WebLink[A New Kind of Science, http://www.wolframscience.com/nksonline/]))}})}})