Tagged Questions

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

learn more… | top users | synonyms (3)

2
votes
2answers
77 views

How can I generate a variable-length list of options in PieChart?

I would like to allow a user to manipulate the segments of a pie-chart, which is to be generated from a list of a specific format. The code looks something like the following: ...
11
votes
4answers
651 views

List comprehension in Mathematica

Python supports a concept called "list comprehensions". Following is sample example ...
13
votes
11answers
859 views

How to get list of duplicates when using DeleteDuplicates?

This might be easy, but can't find a way to use DeleteDuplicates to get also list of the actual duplicates. Example: ...
0
votes
0answers
63 views

How to delete duplicated sublist [duplicate]

I have a list like this: ...
-1
votes
2answers
224 views

How can I extract when a select condition is met in a do loop the value of the iterator?

I use the following code to find out the number of consecutive prime numbers using a formula $n^2+n+i$ found out by Euler (starting from n=0): ...
5
votes
6answers
193 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}, ...
12
votes
4answers
349 views

How to enumerate all possible binary associations?

Suppose I have a list of symbols like: {a,b,c,d} I would like to enumerate all possible binary associations (combining symbols and/or sublists pairwise): ...
0
votes
3answers
100 views

List of squareful, cubeful, etc. numbers

The following works: ...
4
votes
2answers
117 views

How to constrain the generation of all possible orderings?

Here is code from Simon Woods' answer for getting all possible weak (equal ranks allowed) orderings for $N=3$ objects: ...
1
vote
2answers
196 views
11
votes
7answers
388 views

Concatenation of lists in a Fibonacci-like pattern

I am trying to create a List of elements that follow the general pattern: $$X_{n+1} = X_n X_{n-1}$$ where the operation on the right hand side is concatenation, i.e., joining. I want to achieve the ...
0
votes
3answers
96 views

How to get the indices of values in a list which are NOT an specific integer?

I got a real array A, where Dimensions[A] == {5000, 5000, 5}. Some of the values in A are ...
4
votes
2answers
175 views

How to insert / merge a list into another list?

Background: I am working on a 2D geometry algorithm where I need to insert a list of 2D points into another list of 2D points. Somewhat to my surprise I found no Mathematica function capable of doing ...
11
votes
3answers
455 views

How can I remove the singleton dimensions of an array? [duplicate]

If I have an array A, for which Dimensions[A] is {9, 9, 1, 1, 3, 4}, how can I convert ...
9
votes
2answers
480 views

Filtering and Replacing outliers

I have a set of data that measurements of temperature vs time (date). It is easy to realize when the sensor went wrong as one might see a blip on the data. How to teach to Mathematica to: 1) Detect ...
2
votes
2answers
122 views

Interpolating a list with exclusion [closed]

I have a list, data, where the elements data[[i]] range over i from ...
2
votes
5answers
192 views

How do I find the maximum value from the given set of data?

I have a set of data like {{x1, y1},{x2, y2}, ...,{xn, yn}}. From this data can I find the value of x for which ...
0
votes
1answer
83 views

Use a pre-computed list instead of RandomInteger

I would like to replace RandomInteger[{1, 10}, {10, 10}] in the following code: ...
5
votes
2answers
197 views

Interactive grid

I would like to create an interactive grid, whereby one number from a grid is selected by the cursor ("3" in the example below), and all other numbers in the grid are highlighted that are related to ...
0
votes
2answers
160 views

Combining graphics & lists / tables

I have: created with: ...
1
vote
1answer
140 views

How can I pass in parameters for multiple controls to a function that returns a Manipulate?

For instance, I have a some "commands" that I use regularly, for example: ...
0
votes
1answer
147 views

Interpolation problem on the list

I have a List of Latitude, Longitude and Measurement. a = {{{93, 104}, 290}, {{94, 103}, 292}, {{95, 105}, 291}, {{97, 109}, 294}, {{97, 102}, 295}}; And, I ...
0
votes
1answer
119 views

replace is not happening for specific vector valued expression

Given x[t_] := {Subscript[x, 1][t], Subscript[x, 2][t]} following replace works fine x[t] /. x[t] -> 0 0 but following ...
5
votes
4answers
187 views

How to delete mirror symmetric point pair efficiently

Look at following pic There are five points, I can generate the following point pairs ...
8
votes
4answers
297 views

Generate PrimePower counting function

Is there a way to generate a counting function for prime powers - i.e. to create a similar function to PrimePi, but including prime powers. The following will, of ...
1
vote
2answers
115 views

Delete duplicates from hierarchy of lists

Is it possible for Mathematica to compare a number of lists of different sizes, and delete duplicates in a hierarchical manner? For example, given the following lists: ...
1
vote
3answers
198 views

Generating a list of cubefree numbers

I am trying to generate a list of cubefree numbers (i.e. numbers when prime factorized contain no tripled factors) within a given range. Of DivisorSigma, ...
3
votes
1answer
71 views

Why does Thread FileDate give an error message?

I tried for example Thread[FileDate[FileNames["new*", "h:\\temp\\", 1]]] It gives FileDate::fstr: File specification ...
2
votes
2answers
198 views

Iteration problem

I am trying to write a simple program - perform f1 as long as t is smaller than 800. t is ...
19
votes
5answers
478 views

How to split list into disjoint lists?

I wonder if there is any simple way to split a list into its disjoint sublists, e.g. from list={{a,b},{e,f},{b,c},{c,d},{f,g,h}} get a result ...
0
votes
0answers
43 views

is there a way to speed up rule replace? [duplicate]

I am currently doing calculation with 7 parameters, each parameter set corresponding to a value. And I store the data in the format as a list of rule, like following ...
2
votes
2answers
255 views

Covariance of a P x M x N matrix

I have a stack of tiff files. When imported to Mathematica, they form a $P \times M \times N$ matrix, where $P$ is the number of single images in the stack, $M$ is the number of horizontal pixels and ...
0
votes
4answers
95 views

Seek a quick way to bring standard order back to original after Complement [duplicate]

the Complement gives result in standard order. But that's not what I want. I want it to keep the original order. say I have a list ...
0
votes
1answer
200 views

Passing lists to functions in a manner that works like pass-by-reference in other languages?

Is it possible to use a list as a variable, i.e., to pass it by reference to a function? In particular, I have a two-dimensional array and a function to get one element specified by its position: ...
5
votes
7answers
410 views

How to find the longest matching sublists in a list

Given a list of 2D points, i.e. {p1, p2, ..., pn} the list may contain equal points, i.e. pi = pj. In this case it may also be true that a sublist of ...
4
votes
1answer
124 views

Timing Total crashes kernel

Here is a simple test function test[n_] := Module[{i = 0}, Total[Nest[{++i, #}&, {0}, n], -1]] On my system V9.0.1 running OS X 10.6.8 and with a clean ...
2
votes
4answers
595 views

ListPlot multiple datasets over same x-values

Is there a better way to enter my data into a list plot? ...
5
votes
4answers
232 views

How to split a list with respect to its nested sublists?

I have a problem with the following task: having some nested list list = {{k6},{k1,k3,k5},{k7}} I would like to replace all sublists by their permutations and ...
2
votes
6answers
212 views

Manipulating List

I have a list: b={{1, 1}, {2, 2}, {3, 3}, {5, 5}, {6, 6}, {8, 8}, {10, 10}} I want to insert the elements in this list: ...
1
vote
0answers
71 views

The number of real values assumed by combinations of complex roots of a decic

Define complex conjugate as the pair of complex numbers $a+bi,a-bi$. Assume you have 5 such pairs and they are the 10 roots $x_i$ of a 10th-deg equation with integer coefficients. In general, how many ...
6
votes
9answers
668 views

combining and comparing lists

I have 2 lists (of lists), where most of the contained lists match. That is, the lists contained in list1 mostly match the lists contained in list2. In this simplified example each of the inner ...
14
votes
5answers
356 views

Partitioning a list of numbers the Mathematica way

I have two sorted lists, one list will be called the "fences" and the other the "values" Fences could be: $\{1, 5, 9, 14\}$ Values could be $\{-1, 1, 3, 4, 6, 9, 10, 13, 14, 15\}$ I want to ...
1
vote
4answers
197 views

Add Brackets to a string list

Hello stackexchange community! I have a stringlist with a value and his error for eg: {{"12","1"},{"13","2"}} Now i want to output this as something like this ...
3
votes
4answers
209 views

Pattern matching in nested lists

I'm sure this has been asked before, but I can't find the right combination of search keywords to find it. Apologies. I want to do a ReplaceAll on a list of lists, ...
3
votes
2answers
129 views

How to partition a list according to a nested table structure?

This question is related to this quesion. The goal is to use ParallelMap to map a function to a nested Table to get the ...
-1
votes
1answer
161 views

Efficient Table Generation & NDSolve Error

I'm currently working on solving an SEIR model with data from the CDC. I've created a function to calculate the Square difference for the model and want to create a table of values for the 4 variable ...
3
votes
3answers
141 views

Lists - pairing up

I have two (fairly large) lists of equal length & would like to pair them up. eg - from: a = {{0, 1}, {0, 2}, {0, 3}}; b = {{1, 2}, {1, 3}, {1, 4}}; I would ...
1
vote
3answers
243 views

Matlab-style Find in Mathematica? Value list and Boolean List, how to select values according to the boolean list?

I want to select elements with the true value (Indices list) in the corresponding point to the value list (MCS). Is there anything like Matlab-style Find to get the indices of true values in the ...
1
vote
3answers
103 views

ArrayRules for a ragged list

Let there be a sample list as , l = {a, {{b, c}}, {d, e}, {f}, {{g, {y}, u, h}, {{{{k, j}}}}},k, {{{{q}, {w}, {r}, {x}}}}}; ArrayRules[l] ArrayRules::rect: ...
2
votes
1answer
98 views

Putting values into a grid after iteration process

I'm developing a model of thermodynamic cycle in Mathematica. I wrote several functions, applied them to a list containing starting values and iterated, for the model to converge. ...