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

learn more… | top users | synonyms (5)

5
votes
1answer
647 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 ...
5
votes
2answers
422 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 ...
5
votes
1answer
421 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: ...
5
votes
2answers
195 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: ...
5
votes
3answers
138 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 ...
5
votes
1answer
162 views

question about Inner [duplicate]

question1: (code 1 something wrong, Why? and how to overcome this to achieve the next code's effect) ...
5
votes
1answer
176 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 ...
5
votes
4answers
451 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 '...
5
votes
1answer
95 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 ...
5
votes
1answer
105 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 ...
5
votes
3answers
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:...
5
votes
2answers
370 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 ...
5
votes
2answers
174 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 ...
5
votes
3answers
230 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}] ...
5
votes
1answer
199 views

MapThread over large graph

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}\...
5
votes
5answers
251 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}, ...
5
votes
1answer
155 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 <...
5
votes
1answer
234 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 ...
5
votes
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? ...
5
votes
3answers
132 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 ...
5
votes
3answers
193 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 ...
5
votes
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 ...
5
votes
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 ...
5
votes
2answers
249 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. ...
5
votes
1answer
198 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 ...
5
votes
1answer
187 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 ...
5
votes
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)....
5
votes
1answer
149 views
5
votes
3answers
256 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 ...
5
votes
1answer
217 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 ...
5
votes
2answers
290 views

Integrating a list of functions

For the purpose of this minimal example, let's say we have a list of functions, like this: f[y_?NumericQ] := {NIntegrate[z*y, {z, 0, 1}], a y} I want to ...
5
votes
1answer
404 views

An easier and more efficient way to combine lists?

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 ...
5
votes
1answer
250 views

Timing differences between multiple executions of identical code

I have a list of pairs of numbers and I'd like to change the sign of the second element in each pair i.e. $(a,b)\rightarrow (a,-b)$. I'm sure there are many ...
5
votes
1answer
746 views

Computing the distance between two curves obtained from image data?

I've got some image data that I've binarized. The image contains two curves, from which I'd like to compute the distance between (eventually computing an average radius for each point in the picture)....
5
votes
2answers
90 views

Overlap between lists of sublists with different dimensions

I have two lists of sublists. The sublists in the first list contain three elements while the points in the second list contain four e.g.: ...
5
votes
1answer
130 views

Why does my MapThread expression fail in this case?

This morning, I opened one of my previous notebooks and evaluated it. Surprisingly, the code produced an error. This took me a whole four hours to find the problem and it is with ...
5
votes
1answer
244 views

How can I add a mesh over this?

How can I add a mesh over the following 3D plot? ...
5
votes
1answer
326 views

Generating repeated elements in a list [closed]

Is there a function in mathematica that allows you to generate repeated elements inline within a list. For example, let's say you provided this as input text: {1, 2, 3, 4, Repeat[5,3], 6, 7} ...
5
votes
2answers
137 views

How to use Manipulate to cycle through a list of lists over a function

So I can do something like this which I like: Manipulate[i, {i, {1,2,3,4}}] It lets me pick which specific values I want to allow to be chosen for my function. ...
5
votes
2answers
363 views

Building conditional lists with Manipulate

I'm trying to select elements of a list that satisfy some criteria using Manipulate[]. Given 2 lists: ...
5
votes
1answer
195 views

What is the fastest way to maintain a large set of expressions?

In my algorithm I need to maintain a set (an unordered list of distinct elements) of expressions supporting two operations: Test an expression for membership in the set Adding a new expression to ...
5
votes
5answers
353 views

Adding elements in the sublists

How can I add the elements in the sublists? For example, if I have the list which is m={{1,3},{2,3},{4,1}} then, the output that I want is ...
5
votes
1answer
132 views

RankedMax and Max do not behave identically

I have spent three hours debugging some code and at the end I think I found a bug. Otherwise I cannot explain what I am seeing: When I want to use RankedMax on ...
5
votes
1answer
97 views

ListConvolve with Padding -> Fixed?

The built-in function ImageConvolve takes a Padding option that "specifies what padding to use when extending beyond the ...
5
votes
2answers
414 views

TemporalData, RandomFunction, Loops: Extracting data from TemporalData sets?

I'm doing a finance project for my differential equations class to explore stochastic processes. I'm exploring IRA retirement funds. From the project write-up: Standing assumption: at time of ...
5
votes
1answer
644 views

Numbering element in descending order

How can I numbering the elements in descending order of second elements of sublists? For example, if I have the list which is ...
5
votes
1answer
117 views

How to increase speed of iterations with nonlinear functions

Let me ask about part of a problem which I have in solving of a nonlinear DE (numerically). I am working with vectors of length $xN$. I have an initial vector $v$, a given $xN\times xN$ matrix $A$ and ...
5
votes
1answer
99 views

Fast 1D BinCounts Alternative

I have lots of data which looks like this example: ...
5
votes
2answers
129 views

Levelspec range with negative levelspec

Documentation states A negative level -n consists of all parts of expr with depth n. However, it is not clear what do ...
5
votes
1answer
117 views

Amount of k-sized not-duplicated subsets of subsets of pair with disitinct sorted integers

I have a list, L, of this kind ($n\in \mathbb{N}$): L=Sort[RandomSample[Subsets[Range[n],{2}],RandomInteger[{1,Binomial[n,2]}]]] S contains any k-sized subset ...