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

learn more… | top users | synonyms (3)

8
votes
4answers
432 views

Best way to modify values in a list of rules?

Recently I had to solve a problem similar to this: Let's say I have a list of list of rules ...
8
votes
2answers
166 views

Behavior of Inner depends on List dimensions?

Consider the following case: ...
8
votes
2answers
173 views

How to partition a list according to a value in the list

I have a list of the form $\{\{d_1,c_1\},\{d_2,c_2\},\ldots,\{d_n,c_n\}\}$. The values c_i take values between $1,\ldots,k$. I want to partition the data into $k$ lists according to the values $c_i$. ...
8
votes
3answers
300 views

Deleting quasi-duplicates from large list efficiently

I have the need to remove "duplicates" from large (>10K members) lists, where a "duplicate" is either a verbatim duplication, or the element's second entry exists as a first entry for some "earlier" ...
8
votes
1answer
296 views

How can I define a Listable function only apply to a vector?

Consider the function f which should behave as f[{{1, 2}, {3, 4}, {5, 6, 7}}] ...
8
votes
1answer
287 views

DeleteDuplicates[] does not work as expected on floating point values

Here is my simple example, and in this case function DeleteDuplicates does not work as expected. I want to FindRoot of my ...
8
votes
2answers
841 views

Rapidly binning 3D data

I have a set of data (about 20 million datapoints for my real data) of the form {x, y, z, m}. There are 3 spatial coordinates x, ...
8
votes
2answers
361 views

Aligning two lists

I have two lists, L1 and L2, each with a key and some data. Let us say the key is a person's name, a string, and the data follows. (To respond to rasher's query:) Let us also assume the lists are ...
8
votes
1answer
206 views

Transformation rule on a list of non-negative integers

I am trying to create a transformation rule that takes a list of non-negative integer values of any length, finds a non-zero entry in the list, adds 1 to all preceding numbers, subtracts 1 from the ...
8
votes
3answers
802 views

Analytically finding critical values in a hysteresis curve made with ListPlot

Let me start with a super basic explanation of what I'm trying to do, and I will follow with a more detailed discussion afterwards. From data in the form shown below (a ...
8
votes
1answer
294 views

Elementwise, compilable min function

I am trying to implement efficiently a transfer-matrix like algorithm. On each iteration, I have two vectors $x=\{x_1,\dots,x_n\}$, $y=\{y_1,\dots,y_n\}$ with real numbers and I need to compute the ...
8
votes
1answer
137 views

Strange behavior of BinCounts

Bug introduced in 8.0 and fixed in 10.0.0 Just try this example: ...
8
votes
1answer
311 views

How to remove some elements in a list based on a rule?

I want to deal with the following list. mylist = Table[cof[i] exp[i], {i, 1, n}]; (*n is very larege *) exp[ ] is a function ...
8
votes
0answers
147 views

How to merge Datasets representing matrices with named rows/columns?

I am working with square (non-symmetric) matrices with named rows and columns. The data I receive is sometimes messy and rows/columns may come in various permutations. I usually need to ...
8
votes
0answers
234 views

Learning Resources for Data Science in the Wolfram Language

I'm delivering an upcoming course on Data Science with the programming/analysis done predominantly in the Wolfram Language. I created the following table to leverage students' familiarity with Lists ...
7
votes
4answers
513 views

Prepend 0 to sublists

My question is similar to this one, but my goal is to prepend a single 0 the each sublist, not incrementally many 0's. The file I'm working is a CSV containing around 50K sublists of length 35. I've ...
7
votes
6answers
1k views

Simplifying nested If statements

Consider : list = {100,102,103,99,106,107,104,112} I want to consider, extract only the "big moves" of that time series. In this case the moves bigger then 5 ...
7
votes
4answers
596 views

Filter a list generated with Tuples

I generated with Tuples[{{1, 2, 3, 4, 5}, {1, 2, 3, 4, 14}, {1, 2, 3, 4}, {1, 2, 3, 4}, {1, 5, 6, 7, 8}, {5, 6, 7, 8, 10}, {5, 6, 7, 8}, {5, 6, 7, 8}}] ...
7
votes
9answers
438 views

Convert list of lists to cumulative join

I have this: list[1]={1,2,3}; list[2]={7,8,9}; list[3]={15,20,22}; I want this: ...
7
votes
4answers
586 views

How to find all data points within closed curve

I want to find all data points inside curve as given below: ...
7
votes
7answers
439 views

How to pick an element of a row corresponding to the minimum in a particular column?

How can I find what value in column 1 of my list corresponds to the minimum value in column 2?
7
votes
5answers
311 views

Manipulating a sublist based on position

I have a huge list with huge sublists of the form list={{a,b,c,d},{e,f,g,h},{i,j,k,l}} I am looking for a way to manipulate these sublists based on the positions ...
7
votes
5answers
629 views

remove -1 values from a list

I would like to turn a list which looks like this one: {{-1, -1, -1}, {-1, 2, 3}, {-1, -1, 2}, {2, 3, 4}} into one which looks like that one: ...
7
votes
5answers
286 views

Making a table with elements like {10i+j, i, j}

Table[10i+j,{i,4},{j,3}] will generate a table that looks like this: {{11,12,13},{21,22,23},{31,32,33},{41,42,43}} I would like ...
7
votes
3answers
166 views

List has a date and amount, I need to create a cumulative amount by date

I have a list which has a date and a amount, I need to create a list that has the cummulative total with the date. I have the following result: ...
7
votes
5answers
325 views

Find positions of duplicates that are neighbours

Assuming the following list {1,2,3,3,5,6,3} I would like to get the position of values that are next to each other and are duplicates. That is, the output should be {3,4}. Thank you for any help. ...
7
votes
6answers
356 views

The locations of (row-wise) minimum elements in a list

I have a list representing a 2D matrix, such as this 3 ⨉ 2 one: {{2.1, 1.01}, {0.01, 7.2}, {7.8, 2.0}} Does anyone know how to find the minimum of each row, ...
7
votes
4answers
534 views

Using MapThread on list of lists

Just a light weight question for learning. If you think this was asked before, please feel free to close it. I am trying to learn MapThread more, and wanted to use ...
7
votes
3answers
223 views

How to Flatten Array of Arrays of the highest order in a simple way?

I have a matrix of matrices, given in the following code. I want to flatten the array... ...
7
votes
5answers
234 views

Better way to make a certain list with palindromic sublists

Here is my code, which works, but seems a little too long, I think might be a more refined version. ...
7
votes
3answers
758 views

Filtering elements from a list

Suppose that I have a list {{{2, 1}, {4, 3}, {2, 4}}, {{2, 1}, {4, 3}, {3, 1}}, {{2, 1}, {2, 4}, {3, 1}}, {{4, 3}, {2, 4}, {1, 2}}} I want to make a new list ...
7
votes
2answers
225 views

How to generate Intervals from a given list?

If I have a list list={3,7,4,5,1} how to get the List of Intervals /Ranges result = {{1,3},{3,4},{4,5},{5,7}}
7
votes
5answers
191 views

Selecting terms from a matrix

There are similar questions to this on the forum but none fit the purpose here: I would like to extract certain elements of a matrix depending on whether a factor is present or not, and create ...
7
votes
6answers
200 views

How to join held Lists?

Let's say I have a = Hold@{2+2} b = Hold@{4+4} How can I get Hold@{2+2,4+4} ie join the two held lists ? More ...
7
votes
4answers
616 views

How make f[{x,y}] evaluate as f[x,y]?

I frequently encounter the situation where I have a function of two real variables defined, e.g.: f[x_, y_] := 9 - x^2 - y^2 But then I need to feed into ...
7
votes
4answers
401 views

Computing a map between two lists

What I want is a little difficult to explain. So I try to it with an example. I have 2 lists, each of which has $(n-1)^2$ elements. Each element is an integers between 0 and $n-1$, inclusive. For ...
7
votes
5answers
319 views

How to display operations on list elements

When applying some arithmetic operation on two lists, I'd like to display the actual operations between the elements of each list. For example, {1, 1} + {1, -1} ...
7
votes
2answers
252 views

Threading behavior of SameQ vs Equals

I ran into a bug in my code today based on an errant assumption. Namely, I thought that: ...
7
votes
2answers
249 views

Is there a function which instantly tells you whether an element is part of a list?

I have a very long list of numbers and I want to check whether there's a function (something that would look like PartOfQ[element,list]) that tells you immediately ...
7
votes
3answers
1k views

Simulate MATLAB's meshgrid function

Here is MATLAB's meshgrid. I came up with these implementations in Mathematica: ...
7
votes
3answers
274 views

Numbering nested list according with Depth (or Level)

(This question is slightly similar with Sequentially numbering a nested list, but not exactly the same.) What I want Say I have a nested list ...
7
votes
4answers
229 views

Button's command is not evaluated in iteration

I wish I didn't feel like a newbie after several months, but... If I enter the following: Table[ Button[ "Number: " <> ToString @ i, Print @ i], {i, 1, 5}] ...
7
votes
4answers
307 views

Evaluating a function using arguments from a sliding window over a list [duplicate]

Possible Duplicate: How to Map a subset of list elements to a function? I want to evaluate a function using arguments from a sliding window over a list. As an example, lets use ...
7
votes
4answers
296 views

Unexpected behavior from GatherBy in version 7

I have come across what appears to be a bug in GatherBy. It appears similar to the problem of using Table[Random[], {1000}] in ...
7
votes
3answers
457 views

What is the correct way to conditionally add elements to lists? [duplicate]

Possible Duplicate: How to avoid returning a Null if there is no “else” condition in an If contruct I have several situations where I need to conditionally add an element to a list, at ...
7
votes
4answers
156 views

Is there a good way to map a function over a list to lists exclusively of a certain depth?

Let's say I have some ragged list. If some elements have some depth $n$, then is there a way I can map a function to only those elements? I.e., for some list foo, ...
7
votes
3answers
515 views

How to create a list of pre-defined functions?

I would like to create a list of Cauchy distribution pdf's, having different locations of their maxima, and being multiplied by different factors; then I'd like to calculate those functions' values ...
7
votes
5answers
746 views

Check if two lists are equal in any order

Suppose I have two lists, how can I efficiently check if the two lists are identical up to permutations of the elements? For example I would like the function to output: ...
7
votes
4answers
195 views

Generating all matrices with 1 (possibly) replaced by -1

I have a matrix $M$, whose dimension I am unsure of, which has only $\lbrace0,1\rbrace$ entries. I would like to generate all the possible matrices that result from changing (some subset) of the $1$'s ...
7
votes
2answers
341 views

find subsequences of constant increase

A list like l = {0, 1, 2, 3, 4, 5, 7, 9, 12, 13, 18, 19} may have subsequences of constant increase, $a_{n+1} = a_n + k$. For example: ...