Partition list at repeated element
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
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
add a comment |Â
up vote
3
down vote
favorite
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
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
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
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
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
list-manipulation
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
add a comment |Â
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
add a comment |Â
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
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
add a comment |Â
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
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
add a comment |Â
up vote
3
down vote
Most /@ Split[list, UnsameQ] /. -> (## &)
a, 1, 2, 3, b, 5, 6, c, 1, 5, a, 7, 8, 9
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
add a comment |Â
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
Most /@ Split[list, UnsameQ] /. -> (## &)
a, 1, 2, 3, b, 5, 6, c, 1, 5, a, 7, 8, 9
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
add a comment |Â
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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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