Linked Questions
13 questions linked to/from Partitioning a list when the cumulative sum exceeds 1
21
votes
14
answers
1k
views
Partitioning a list based on a criterion for sublists
SeedRandom[1];
alist = RandomInteger[{1, 10}, 20]
{2, 5, 1, 8, 1, 1, 9, 7, 1, 5, 2, 9, 6, 2, 2, 2, 4, 3, 2, 7}
I would like to divide this list into sublists (...
78
votes
9
answers
12k
views
How to efficiently find positions of duplicates?
Is there an efficient way to find the positions of the duplicates in a list?
I would like the positions grouped according to duplicated elements. For instance, given
...
17
votes
9
answers
2k
views
Splitting a list into increasing sublists
I have a list of numbers (say, for example, {1,2,3,4,3,2,1,2,3,4,3,2}), and I want to split it into sublists so that each sublist is the (smallest) sublist whose ...
41
votes
8
answers
3k
views
Can this be written well, without loops?
Inspired by this question I would like to know if the following code can be written without explicit loops (For, While, etc.) in a clean, efficient and non-contrived way. I have been unable to do so.
...
11
votes
7
answers
719
views
Partition a list by count of a number
I want to take this list when the 2 appear 3 times
SeedRandom[1]
list = RandomChoice[{.2, .5, .3} -> {1, 2, 3}, 20]
...
10
votes
7
answers
827
views
Is there concise code for the list operation I want to perform?
Is there any concise syntax for the following partitioning of a list. Given
{1, 2, 3, 4}, I want to get the output as shown below. I have tried various function ...
8
votes
7
answers
418
views
While partitioning the elements in a list using GatherBy, can I correspondingly partition the elements of an unrelated list?
If we have a list like the following:
list1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
And we use GatherBy to subpartition is ...
12
votes
6
answers
1k
views
How do I split a list of numbers to monotonic sequences?
Suppose I have:
list = {1, 2, 4, 5, 7, 11, 8, 7, 3, 1, -3, -2, 6, 7, 80}
And I want to split it to:
...
8
votes
6
answers
3k
views
Simplifying nested If statements
Consider :
list = {100,102,103,99,106,107,104,112}
I want to consider, extract only the "big moves" of that time series. In this case the moves bigger then 5 ...
22
votes
4
answers
784
views
Getting lengths of sublists that sum to more than one
I have a long list of numbers, and I'm interested in finding the length of each sublist that totals to more than 1, so for the list
...
11
votes
3
answers
318
views
Grouping by total length of elements grouped
How might one split a list of irregularly-long sublists into groups, each of which is shorter than a specified length?
For example, given the following input:
...
3
votes
3
answers
169
views
Variable iterator in Do Loop (splitting a list)
I have a list in Mathematica that looks like the following:
{{92,3},{23,3},{93,3},{63,2},{66,2},{24,4},{94,4},{27,4},{72,4},....}
The point is that the second ...
2
votes
1
answer
288
views
Automatic text-wrapping in labels in `TimelinePlot`
Part-related to this question and part-related to this one, I would like to make use of the new features of TimelinePlot in 10.3, but would like to incorporate some ...