Linked Questions

2
votes
2answers
2k views

How to append to a list of lists elegantly [duplicate]

I have have list of lists and I would like to be able to append an element to the start of each list. I am sure there must be an elegant solution. EG: a and ...
0
votes
0answers
63 views

Fastest way to add a constant column into a array [duplicate]

What is the fastest way to add a constant (1 in this test) into a array? There is my attempt: ...
96
votes
4answers
5k views

Flatten command: matrix as second argument

One thing I could never wrap my head around is how Flatten works when provided with a matrix as the second argument, and the Mathematica help isn't particularly ...
49
votes
3answers
1k views

Are there guidelines for avoiding the unpacking of a packed array?

Packed arrays are very useful because they save memory and generally allow speedier and more efficient calculation times. If a list of data currently stored as a packed array is unpacked, it can slow ...
40
votes
2answers
12k views

How to form a block-diagonal matrix from a list of matrices?

For example, like this: I know Join works, but it is a bit troublesome for multiple matrices. I also tried DiagonalMatrix, but ...
16
votes
5answers
725 views

Interlacing a single number into a long list

This seems like it should be a simple question, but I am running into some difficulty in doing this with Mathematica. Right now, I have a list like this: ...
46
votes
2answers
2k views

How do you set attributes on SubValues?

SubValues, as discussed in a previous question, are declared as follows ...
7
votes
9answers
531 views

Prepending a constant value to sublists of a list

I have a list: ...
10
votes
8answers
1k views

Adding elements to a collection of lists

I would like to add element a at the start of a series of lists. For example I have a collection of lists called ...
12
votes
6answers
492 views

Most efficient way of making pair list from a list

I have a bunch of datasets which look like: 3 7 1 6 5 8 2 4 1 2 8 1 5 2 5 ... and I need to make a list of pairs such that the first element makes a pair with ...
6
votes
5answers
370 views

How convert list of numbers to list of points on x-axis? [duplicate]

I have a list of real numbers, say: vec = RandomInteger[{1, 20}, 6] (* {2, 4, 7, 10, 13, 6} *) I want to convert each of these numbers to the corresponding ...
12
votes
3answers
798 views

Riffle and Partition

At some point I noticed that I was using Riffle and Partition together a lot. I would do things like ...
4
votes
4answers
160 views

Combining list elements

I am doing the following: ...
5
votes
3answers
99 views

Inserting columns multiple times

I think this question is very simple and will be closed, but I'm left with doubts. ...
3
votes
2answers
205 views

Appending multiple elements to sublists

In short, I look for a concise definition of a function in Mathematica that calculates the following: $f\left(\begin{pmatrix}a_{11}&\dots&a_{1m}\\\vdots&\ddots&\vdots\\a_{n1}&\...

15 30 50 per page