Partition list at repeated element

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite
1












I have a long flat list that needs to be partitioned. The list is formatted so the "header" is repeated, followed by the values. Essentially, it looks something like this:



list=a,a,1,2,3,b,b,5,6,c,c,1,5,a,a,7,8,9,1


I am looking for an output of:



a,1,2,3,b,5,6,c,1,5,a,7,8,9,1


The output above would then let me create the association list I need.



Obviously Partition won't work because the sublists are of different lengths. I have looked at various ways to identify where the repeated "header" data is, but that doesn't help with the splits.










share|improve this question





















  • What is the header data? Is it symbols? Or a string? Or also numbers?
    – Henrik Schumacher
    1 hour ago










  • In the actual data, all items would be treated as strings
    – kickert
    1 hour ago










  • Should the list be split any duplicate or are there some known header strings?
    – Henrik Schumacher
    1 hour ago










  • All headers will repeat and none of the following values will repeat. There is a chance that sets will have the same headers. Essentially, anytime a value is equal to the value before it, it can be used as the split point.
    – kickert
    52 mins ago














up vote
3
down vote

favorite
1












I have a long flat list that needs to be partitioned. The list is formatted so the "header" is repeated, followed by the values. Essentially, it looks something like this:



list=a,a,1,2,3,b,b,5,6,c,c,1,5,a,a,7,8,9,1


I am looking for an output of:



a,1,2,3,b,5,6,c,1,5,a,7,8,9,1


The output above would then let me create the association list I need.



Obviously Partition won't work because the sublists are of different lengths. I have looked at various ways to identify where the repeated "header" data is, but that doesn't help with the splits.










share|improve this question





















  • What is the header data? Is it symbols? Or a string? Or also numbers?
    – Henrik Schumacher
    1 hour ago










  • In the actual data, all items would be treated as strings
    – kickert
    1 hour ago










  • Should the list be split any duplicate or are there some known header strings?
    – Henrik Schumacher
    1 hour ago










  • All headers will repeat and none of the following values will repeat. There is a chance that sets will have the same headers. Essentially, anytime a value is equal to the value before it, it can be used as the split point.
    – kickert
    52 mins ago












up vote
3
down vote

favorite
1









up vote
3
down vote

favorite
1






1





I have a long flat list that needs to be partitioned. The list is formatted so the "header" is repeated, followed by the values. Essentially, it looks something like this:



list=a,a,1,2,3,b,b,5,6,c,c,1,5,a,a,7,8,9,1


I am looking for an output of:



a,1,2,3,b,5,6,c,1,5,a,7,8,9,1


The output above would then let me create the association list I need.



Obviously Partition won't work because the sublists are of different lengths. I have looked at various ways to identify where the repeated "header" data is, but that doesn't help with the splits.










share|improve this question













I have a long flat list that needs to be partitioned. The list is formatted so the "header" is repeated, followed by the values. Essentially, it looks something like this:



list=a,a,1,2,3,b,b,5,6,c,c,1,5,a,a,7,8,9,1


I am looking for an output of:



a,1,2,3,b,5,6,c,1,5,a,7,8,9,1


The output above would then let me create the association list I need.



Obviously Partition won't work because the sublists are of different lengths. I have looked at various ways to identify where the repeated "header" data is, but that doesn't help with the splits.







list-manipulation






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 1 hour ago









kickert

55215




55215











  • What is the header data? Is it symbols? Or a string? Or also numbers?
    – Henrik Schumacher
    1 hour ago










  • In the actual data, all items would be treated as strings
    – kickert
    1 hour ago










  • Should the list be split any duplicate or are there some known header strings?
    – Henrik Schumacher
    1 hour ago










  • All headers will repeat and none of the following values will repeat. There is a chance that sets will have the same headers. Essentially, anytime a value is equal to the value before it, it can be used as the split point.
    – kickert
    52 mins ago
















  • What is the header data? Is it symbols? Or a string? Or also numbers?
    – Henrik Schumacher
    1 hour ago










  • In the actual data, all items would be treated as strings
    – kickert
    1 hour ago










  • Should the list be split any duplicate or are there some known header strings?
    – Henrik Schumacher
    1 hour ago










  • All headers will repeat and none of the following values will repeat. There is a chance that sets will have the same headers. Essentially, anytime a value is equal to the value before it, it can be used as the split point.
    – kickert
    52 mins ago















What is the header data? Is it symbols? Or a string? Or also numbers?
– Henrik Schumacher
1 hour ago




What is the header data? Is it symbols? Or a string? Or also numbers?
– Henrik Schumacher
1 hour ago












In the actual data, all items would be treated as strings
– kickert
1 hour ago




In the actual data, all items would be treated as strings
– kickert
1 hour ago












Should the list be split any duplicate or are there some known header strings?
– Henrik Schumacher
1 hour ago




Should the list be split any duplicate or are there some known header strings?
– Henrik Schumacher
1 hour ago












All headers will repeat and none of the following values will repeat. There is a chance that sets will have the same headers. Essentially, anytime a value is equal to the value before it, it can be used as the split point.
– kickert
52 mins ago




All headers will repeat and none of the following values will repeat. There is a chance that sets will have the same headers. Essentially, anytime a value is equal to the value before it, it can be used as the split point.
– kickert
52 mins ago










1 Answer
1






active

oldest

votes

















up vote
3
down vote













Most /@ Split[list, UnsameQ] /. -> (## &)



a, 1, 2, 3, b, 5, 6, c, 1, 5, a, 7, 8, 9







share|improve this answer




















  • That seems to have done it. Let me dig into the final output to see if there is any trickery going on.
    – kickert
    50 mins ago










Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f182307%2fpartition-list-at-repeated-element%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote













Most /@ Split[list, UnsameQ] /. -> (## &)



a, 1, 2, 3, b, 5, 6, c, 1, 5, a, 7, 8, 9







share|improve this answer




















  • That seems to have done it. Let me dig into the final output to see if there is any trickery going on.
    – kickert
    50 mins ago














up vote
3
down vote













Most /@ Split[list, UnsameQ] /. -> (## &)



a, 1, 2, 3, b, 5, 6, c, 1, 5, a, 7, 8, 9







share|improve this answer




















  • That seems to have done it. Let me dig into the final output to see if there is any trickery going on.
    – kickert
    50 mins ago












up vote
3
down vote










up vote
3
down vote









Most /@ Split[list, UnsameQ] /. -> (## &)



a, 1, 2, 3, b, 5, 6, c, 1, 5, a, 7, 8, 9







share|improve this answer












Most /@ Split[list, UnsameQ] /. -> (## &)



a, 1, 2, 3, b, 5, 6, c, 1, 5, a, 7, 8, 9








share|improve this answer












share|improve this answer



share|improve this answer










answered 54 mins ago









kglr

161k8185384




161k8185384











  • That seems to have done it. Let me dig into the final output to see if there is any trickery going on.
    – kickert
    50 mins ago
















  • That seems to have done it. Let me dig into the final output to see if there is any trickery going on.
    – kickert
    50 mins ago















That seems to have done it. Let me dig into the final output to see if there is any trickery going on.
– kickert
50 mins ago




That seems to have done it. Let me dig into the final output to see if there is any trickery going on.
– kickert
50 mins ago

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f182307%2fpartition-list-at-repeated-element%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

Long meetings (6-7 hours a day): Being “babysat” by supervisor

Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

Confectionery