# Tagged Questions

Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.

119 views

### Problem with Compile and Flatten

I want to get two lists within a compiled function, where r is an integer: ...
240 views

### Finding the position of a single array in a list of arrays that contains wildcard variables

Consider two lists: superList = {{wc,wc,1,wc,wc}, {wc, wc,2, wc, wc}, {wc, wc, 3, wc, wc}, {wc, wc, 4, wc, wc}}; littleList = {a,b,3,c,25}; In ...
1k views

### Generating random symmetric matrix

Suppose first that I want to generate a matrix whose elements are independent and identically distributed (i.i.d.) with distribution dist. This is easy: ...
138 views

### Comparison Operation for Nested Matrices

I have a nested matrix n as bellow ...
265 views

### Split list of states by run lengths and discontinuous changes in state

I was asked to look into writing some simulation code for a user, where the simulation output (x) would oscillate between three possible states: ...
418 views

### Efficient method for Inserting arrays into arrays

This is strongly related to the following Questions: Looking for a way to insert multiple elements into multiple positions simultaneously in a list Building matrices by attaching vectors (columns) ...
308 views

### How to create this list more elegantly

There is list containing some $(i,j)$ values of indices. Now i want to create a matrix of dimension n $\times$ m whose entries are 1 for the indices corresponding to the given list otherwise its zero....
366 views

### Provided an array of 2D point clouds, can we quickly replace distance- and index-based cliques of points with their median or mean values?

Imagine I have $N \approx 10^5$ clouds of points in an array of the form: UPDATED ...
349 views

### Is there an equivalent of “shiftdim” of MATLAB?

Recently I'm spending my time implementing some computer vision algorithms, which usually handle a large amount of data. The problem I'm facing now is that I have to reform my video data to pass it ...
478 views

### Efficiently extracting an array subset given a separate array

I have two arrays. The first array consists of tens of millions of rows and three columns with a string, a number, and a string. ...
103 views

### Table with List iterator return unpacked list

Table support list as iterator, for example list1=Table[w, {w, Range[1., 10., 0.01]}]; We can confirm that list1 is packed ...
160 views

### Add to matrix missing elements (for list of time series)

This question is an extension of the 43122. I’ve looked through many interesting post (like this) but (as always) missed the direct matching. So the setting is simple: ...
351 views

### Smallest element distance between two lists

I have a problem, where I generate two lists of points, and I want to see which points are the closest. If I just want to find which ones are exactly the same, I can use ...
86 views

### SplitBy problem with Associations

Association keys are supposed to be transparent, but in this reduced example SplitBy fails: ...
205 views

### Counting variable from a list of matrices

I have a list of matrices ...
168 views

### Missing control for depth of Inner

Working on a mechanics problem, I stumbled on something peculiar: Since Inner is a generalisation of Dot, it changes its ...
559 views

### Why is there a huge performance gap using Map with more than 100 List entries

im using Map on a List like this: cube= {{1, 1, 1}, {1, 1, 2}, {1, 1, 3}, {1, 1, 4}, ... , {5, 5, 4}, {5, 5, 5}} Mapping the whole List with 125 entries takes ...
659 views

### Apply color function to matrix plot

I want to apply the following color rules to a large table of numbers. I have extracted a part of the table to use as an example. I would like to assign 5 different colors to 5 different ranges of ...
427 views

### Can someone explain this code for joining two lists by the first element of each sublist?

Background (which may be skipped, unless context is needed) I've recently begun learning Mathematica (and only up to chapter 3 of Wellin), but wanted to write some code to get a better feel for ...
424 views

### Problem with creating a large list of tuples

This is a follow-up question from Sum of Multinomial Coefficients I have thought about the meaning of the formula I mentioned and, with help, I implemented the following code: ...
196 views

### How to efficiently find multimap k-itemset frequency

I am doing this to learn association rules. The data d is in format {id, value}, for example: ...
139 views

### Changing the first row of a matrix; subsequent rows depend on the first row

I have generated a matrix of zeros. tab=Table[0,{i,10},{j,10}] tab is defined such that given ...
179 views

### Find positions where two matrices differ

I have two matrices A and B of identical dimensions. What's the simplest (shortest) way to find the indices of differing ...
162 views

question1: (code 1 something wrong, Why? and how to overcome this to achieve the next code's effect) ...
177 views

### How I can use Apply or Map with If?

I have list of objects: list = {{1, 1, 0.05, 0.05}, {2, 2, 0.05, 0.05}, {13, 13, 0.05, 0.05}}; list = {{x,y,Vx,Vy},{x,y,Vx,Vy},...}; And ...
454 views

### How to simplify block of multiple repetitive If statements?

I'm building a boardgame...game in Mathematica. I have the board state represented as a matrix. It's a two player game, and each player (let's call them A & B) only has one type of piece or '...
96 views

### list of all permuations of sublists of a nested list

I've got a certain class of lists with, say, 4 elements, that are lists themselves. E.g. {{1, 2, 3}, {4}, {5, 6}, {7}}. I'd like to find a way to generate a list ...
109 views

### How to order a list to match the order of another list?

How can I order a list to match the order of anoter list ? For example: Suppose I have the lists x = {3, 1, 5, 7} and ...
190 views

### How to find the right permutation, which fits to the problem?

I'm new here and I hope I can find some help. I'm from Germany, so sorry for my English. I look for a number, whose digits are all different. It isn't known how many digits it has. But there is a rule:...
371 views

### Is there an inequality operator (Less, Greater) for lists of elements (as opposed to elements)?

Like multi-column sorting. For example, {1,3,5} > {1,2,5} would return True, while ...
175 views

### Sorting out atom types in an XYZ file

I am trying to rewrite the output of "VertexCoordinates" such that instead of a hybrid list of atoms and coordinates that result from using the following input program, I want all coordinates of the ...
234 views

### Non-descending Tuples

I want to get all the non-descending tuples of a list with given length, for example: f[{1,2,3,4},{3}] ...
201 views

I am trying to build a very large graph with approximately $16\,000\,000$ edges, each being a two-dimensional integer vector. I have a list of edges in the form $\{\{e_{11}, e_{12}\}, \{e_{21}, e_{22}\... 5answers 252 views ### Reversing every second “row” in a list I have a list that is obtained by flattening a matrix list=Flatten[Table[{i, j}, {i, 1, 4}, {j, 2, 6, 2}], 1] {{1, 2}, {1, 4}, {1, 6}, {2, 2}, {2, 4}, {2, 6}, ... 1answer 156 views ### Assigning Sequence to Part of a SparseArray (bug?) Part ▪ You can make an assignment like t[[spec]]=value to modify any part or sequence of parts in an expression. ▪ If <... 1answer 239 views ### Trouble with Flatten[] I made this function: f[g_] := Table[{ToExpression[ToString[x] <> ToString[n]], 1, 3}, {n, 1, g}] When I evaluate the function with some g (say 8), I'll ... 1answer 386 views ### DeleteCases messing with my mind I'm losing my mind. Please tell me my laptop is doing weird things and not me. Or do I need to get committed someplace? ... 3answers 134 views ### Lazy form of Tuples/Outer to loop over list of lists This is less a question and more asking if someone has implemented this already, with more skill. I need to perform the Outer-like generalized outer product of a ... 3answers 195 views ### DeleteStopwords in other languages? I saw that in new version of Mathematica there is an interesting function: DeleteStopwords that deletes stopwords from a list of words, but this function is only ... 1answer 107 views ### How to get a new list by exchanging some elements? Let's begin with a simple example. Now, we have a list, list0=Range[4]; k1 and k2 are some elements of the list0. If |k1-k2|==2, then the elements k1 and k2 can ... 1answer 213 views ### Slow exponential evaluation over lists This question,which is still unanswered, might be relevant because it involves NIntegrate over lists and it also has Exp. In ... 2answers 250 views ### How to define even permutations correctly? I define even permutations as following, but there may be some error. I use it in two different way and get different output. ... 1answer 199 views ### How to efficiently select element in a list of lists? How can I write an efficient version of the following statement? Cases[list, {_, feature_} /; feature < constant]; // AbsoluteTiming List is of the form, list ... 1answer 188 views ### How to combine matrix with array without cycles? I am new to Mathematica. And I'm sorry for my English. I have created a matrix ($6 \times 4$) and an array ($1 \times 4$). I want to get another matrix that will have the first element from the array ... 1answer 2k views ### Contracting with Levi-Civita (totally antisymmetric) tensor I have an array$v_{ijk}$which is effectively a rank-$3$tensor with dimensions$3\times3\times3$, and I need to contract it with$e^{ijk}$, i.e. evaluate$v_{ijk} e^{ijk}$(see Einstein convention).... 1answer 149 views ### Strange phenomenon with Outer ... 3answers 257 views ### Applying a function with the HoldAll attribute inside NestList I'm trying to write an update function, which can be applied to a list and then to NestList it. As the function has to manipulate the given variable I figured I ... 1answer 218 views ### Why is Flattening a CoefficientArray so slow? I have a vector of$n$degree$n$polynomials in$(x,y,z)$, each of whose coefficients is an inhomogenous linear expression in$3 n^2$variables. I want to write down the linear equations in these$3 ...
I currently have a two lists. The first list contains independent variables $x$, and the second list contains dependent variables in the form of $\{\{f[1][x]\},\{f[2][x]\},...,\{f[n][x]\}\}$. I want ...