Linked Questions
46 questions linked to/from Partitioning with varying partition size
3
votes
1
answer
492
views
Partition a list into sublists of unequal lengths according to a list of lengths [duplicate]
This is a conscious duplicate of On generalizing Partition[] (with offsets) to sublists of unequal length: it was seven years ago, and all answers are quite involved; maybe something easier has been ...
3
votes
0
answers
754
views
Splitting a list into sublists with different sizes [duplicate]
I have the list {7, 8, 9, 10, 11, 12, 13, 14} and would like to split it into a list of size 2, a list of size 3, and covert the remaining element into singleton ...
3
votes
1
answer
96
views
Non-Constant Partitioning of a List with Order Analysis [duplicate]
Let's say I have a set of numbers "r" whose sum equals 15, and I want to randomize all values up to and including that sum from and including 1 into a set called "a". So far I have this:
...
608
votes
19
answers
161k
views
Where can I find examples of good Mathematica programming practice?
I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
79
votes
9
answers
13k
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
...
125
votes
3
answers
10k
views
What is a Mathematica packed array?
A simple sounding question with a few sub questions:
What is the difference between unpacked vs packed array?
Are packed arrays more space efficent, how much so?
Are packed arrays more time efficient ...
46
votes
10
answers
7k
views
Find zero crossing in a list
I'm looking for a function that finds the index of the zero-crossing points of a list. Before I go making my own subroutine to do this, I was wondering if anyone knows of any built-in Mathematica ...
22
votes
12
answers
1k
views
Any built-in function to generate successive sublists from a list?
Given
lst = {a, b, c, d}
I'd like to generate
{{a}, {a, b}, {a, b, c}, {a, b, c, d}}
but using built-in functions only, ...
44
votes
6
answers
4k
views
Mathematica Destructuring
Context
I'm writing a function that look something like:
...
23
votes
10
answers
2k
views
UnFlatten an array into a ragged matrix
Trying to unflatten an array that was part of ragged array of sub matrices.
As input we have flattened array:
...
15
votes
6
answers
2k
views
Efficient conditional Mean[] on a large data set
Consider a list, AK6, that has 382 sublists of length varying from 2500 to 3000. Each "subsublist" is as such : ...
23
votes
6
answers
1k
views
How to generate all possible orderless partitions of a list according to another list?
This question is hard to describe in plain text. So I will post an example and a working code (brute force) to illustrate.
For example I have a list: ...
13
votes
11
answers
796
views
Positions of elements in the initial flattened list in a split list
Say, we have a list:
m1 = {2, 2, 7, 0, 7, 7, 2, 2, 2}
It can be split easily:
...
16
votes
8
answers
3k
views
Populate an upper triangular matrix from a vector of elements
What is the best way to populate an upper triangular (or alternatively: lower triangular or symmetric) matrix from a vector of elements?
This example input:
...
10
votes
6
answers
3k
views
How to efficiently input matrices in Mathematica (compared to what MATLAB offers)
Every time I want to manually input a matrix in Mathematica, it takes me a while since every new row has to be in a separate pair of curly braces.
For instance:
...