# Tag Info

Accepted

### Is there a built-in equivalent to Python's enumerate?

Streaming module - general, and the case at hand Starting with V10.1, there is an undocumented support for certain lazy operations in Mathematica. However, the ...
• 112k
Accepted

### Why do Mathematica list indices start at 1?

I think Leonid's answer deserves to be expanded upon. Most other languages are not symbolic, and thus the "variable name" is not something one needs to keep track of --- ultimately the interpreted or ...
• 5,454

### How to understand the usage of Inner and Outer figuratively?

Animated Mathematica Functions contains cool animated illustrations of the way a number of built-in functions work. Among them are Thread Inner: Outer See also: cormullion's video
• 350k
Accepted

### How to implement the general array broadcasting method from NumPy?

Broadcasting vs Listability NumPy broadcasting lets you perform, in efficient way, element-wise operations on arrays, as long as dimensions of those arrays are considered "compatible" in some sense. ...
• 14.7k
Accepted

### Apply multiple functions to same list

Also, y = {1, 2, 3, 4, 5, 6, 7}; #[y] & /@ {Max, Min, Median, Mean} (* {7, 1, 4, 4} *) EDIT: comparing the timings: ...
• 121k

### Selecting every n-th element from a list

Please look up Part and Span. You can use data[[ ;; ;; n]]
• 225k
Accepted

### DeleteDuplicatesBy is not performing as I'd hoped. Am I missing something?

The behavior described here is the same from 10.0.0 up to at least 10.3. Summary We can look at the code of DeleteDuplicatesBy and it turns out it uses ...

### Apply multiple functions to same list

You can use Through. Through[{Max, Min, Median, Mean}[y]] (* {7, 1, 4, 4} *) Hope this helps.
• 39.4k
Accepted

### Why it seems that there is no counterpart function as to multiplication, to Total` as to addition?

In addition to the previous answer... I designed and implemented Total 17 years ago. Its first version was named ListSum. The ...
• 35.2k

### How to subtract the column means from each row of a matrix?

It is there: Standardize[mat, Mean, 1 &]
• 133k
Accepted

### Can Mathematica put these puzzle pieces together?

Assuming polygons follow the same (clockwise or counterclockwise) vertex order, find all good quality two line segment rigid mappings between polygons without overlap with each other (at least much ...
• 14.7k
Accepted

### Is there a way to riffle more than two lists?

{{a, b, c}, {1, 2, 3}, {x, y, z}} ~Flatten~ {2, 1} {a, 1, x, b, 2, y, c, 3, z}
• 83.5k
Accepted

### Add a vector to a list of vectors

I recommend using Transpose twice since it is more efficient than other approaches. Moreover Plus has the ...
• 54.1k
Accepted

### Mysterious behaviour of Pick

This is not a bug. It is a consequence of the manner in which Pick scans its arguments. The Pick Process The documentation ...
• 67k

### What is a Mathematica packed array?

I would like to point out that Listable in a pure Function effectively unpacks the array, and makes it much slower than Map for ...
Accepted

### How to understand the usage of Inner and Outer figuratively?

I think of Outer just like nikie showed. Inner is a generalization of matrix multiplication. I like the picture from the ...
• 3,773

### How do you concatenate matrices? And how do you make block matrices?

As Daniel Lichtblau suggested in the comment, ArrayFlatten is the way. ArrayFlatten[{{A1, A2}}] // MatrixForm gives your ...
• 5,059

### How to implement the general array broadcasting method from NumPy?

Challenging NumPy's performance will be extremely difficult, and thus the effort of implementing this is not likely to be worthwhile. The reason is that the multiple-transpose method, even though it ...
• 22.5k

### Cyclic Take function?

A variation on Szabolcs's suggestion: overTake = PadRight[##, "Periodic"] &; overTake[{1, 2}, 5] {1, 2, 1, 2, 1}
• 350k
Accepted

### Performance of Select

res1 = Select[coordinates, #[[1]] > 6 && #[[1]] < 7 &]; // AbsoluteTiming // First 6.997629 ...
• 350k
Accepted

### Solving and Animating Three Body Problem

Generally always check Demonstrations site for good code. I cannot not mention an excellent "classic" of planar three body problem by Stephen Wolfram and Michael Trott. Code is short and I verified it ...
• 68.9k
Accepted

### Partition on sublists beginning with a certain marker elements

Split[list, (#2 =!= {a}) &] ...
• 133k
Accepted

### Partitioning a list when the cumulative sum exceeds 1

dat = {0.71, 0.685, 0.16, 0.82, 0.73, 0.44, 0.89, 0.02, 0.47, 0.65}; Module[{t = 0}, Split[dat, (t += #) <= 1 || (t = 0) &] ] ...
• 264k
Accepted

### How was Nothing implemented?

Ok, I failed to find a duplicate so here is my comment: I don't know how Nothing is internally implemented but you can do something like this with ...
• 133k
Accepted

### How to replace all elements of a list by a rule "element" -> "element_"

Here is one way: Pattern[#, Blank[]] & /@ {a, b, c, d, e, f, g, h, i, j} (* {a_, b_, c_, d_, e_, f_, g_, h_, i_, j_} *) An inspection of the ...
• 67k

### Permutations[Range[12]] produces an error instead of a list

Since Mathematica 8 it is possible generate the elements of any group one by one with GroupElements. Here's for example a randomly chosen element of the permutation ...
• 5,921

### Partitioning with varying partition size

New in 11.2 is TakeList: TakeList[Range[10], {2, 3, 5}] {{1, 2}, {3, 4, 5}, {6, 7, 8, 9, 10}}
• 124k

### Converting a list of rules to a list of lists

list = {"Joe" -> 94, "Jane" -> 85, "Bob" -> 82, "Bill" -> 83, "Michelle" -> 98}; List @@@ list {{"Joe", 94}, {"Jane", 85}, {"Bob", 82}, {"Bill", ...
• 34.5k

### How to subtract the column means from each row of a matrix?

Well, transposing, subtracting, transposing... Transpose[Transpose[mat] - Mean[mat]]
• 111k