2
votes
0answers
27 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 ...
424
votes
16answers
96k 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 ...
73
votes
3answers
3k 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 ...
44
votes
6answers
3k 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 ...
39
votes
6answers
3k 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 ...
30
votes
6answers
2k views

Mathematica Destructuring

Context I'm writing a function that look something like: ...
15
votes
9answers
622 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, ...
13
votes
6answers
998 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 : ...
16
votes
8answers
739 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: ...
18
votes
6answers
1k views

On generalizing Partition[] (with offsets) to sublists of unequal length

The usual Partition[] function is a very handy little thing: ...
8
votes
9answers
366 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: ...
8
votes
7answers
1k 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: ...
9
votes
4answers
662 views

How discretize a region placing vertices on a specific non-uniform grid

Given a generic region, for example: Ω = ImplicitRegion[ 2 x^2 + 3 y^2 + 2 x y - 2 <= 0 ∧ x^2 + y^2 > .1, {x, y}]; and a non-uniform grid, for ...
10
votes
5answers
659 views

Count consecutive occurrences in a list above a certain value

I am trying to tally and sort the number of consecutive occurrences in a list above a certain value. For instance: ...
10
votes
5answers
334 views

Split according to List and apply rule

I have a list which looks some thing like this {a1, a2, a3, a4, a5, a6, a7, a8, a9, a10} Now I want to split it according to lengths ...

15 30 50 per page