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

learn more… | top users | synonyms (3)

7
votes
4answers
527 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
428 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
4answers
385 views

Is there a way to riffle more than two lists?

I thought Riffle would generalize such that Riffle[{a,b,c},{1,2,3},{x,y,z}] would return ...
7
votes
5answers
298 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
529 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
285 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
467 views

Sum over binary digits of integer

This might seem like a simple enough question but Mathematica seems to simplify inadequately here: How would you sum over the digits of an arbitrary binary number? I already tried this: ...
7
votes
3answers
165 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
285 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
334 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
3answers
218 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
232 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
4answers
493 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
672 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
221 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
188 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
197 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
539 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
451 views

Find list position and mapping list

Sorry, my English is not very good. I have two lists: ...
7
votes
2answers
246 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
255 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
221 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
3answers
499 views

how to efficiently apply function to all pairs of a set (and collect the results)

To build a graph, I need to apply a function f[a_, b_] to all pairs of a list (3500 elements). The function itself returns a link ...
7
votes
4answers
283 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
424 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
155 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
467 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
4answers
192 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
3answers
531 views

Specifying string patterns in DeleteCases

It seems that DeleteCases is not compatible with string patterns, at least directly (see, for example, this question). Is this true? If so, why is this the case? ...
7
votes
3answers
279 views

How to remove a line of a matrix if not all elements are numeric?

I have a matrix a n columns and m lines. I'd like to efficiently remove the lines that are not entirely composed of numeric ...
7
votes
2answers
329 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: ...
7
votes
3answers
519 views

Add lists with unequal lengths together to create a matrix

I'm trying to create a stacked bar chart using raw data coming from a MySQL server. The result coming back from one query is: ...
7
votes
5answers
319 views

LengthWhile until first duplication

I have the need to trim each of a large number of potentially very long lists (10^6+ elements) to the length where the last occurrence of any distinct element happens, or said another way, where the ...
7
votes
4answers
408 views

Generating an Ulam spiral

An Ulam Spiral is quite an interesting construction, revealing unexpected features in the distribution of primes. Here is a related topic with one answer by Pinguin Dirk, who has provided one ...
7
votes
6answers
233 views

Faster list duplicate 'limiter'

Given some list, e.g., {5, 3, 2, 3, 1, 0, 1, 3, 5, 5, 4, 5, 1, 2, 5, 2, 2, 0, 1, 4}, I need to limit the duplicates, if any, to an arbitrarily chosen number. The ...
7
votes
3answers
259 views

When does a list contain only ones?

I am starting with a list of length n that contains all -1's. For instance, when n = 6 the list is {-1, -1, -1, -1, -1, -1}. I ...
7
votes
2answers
241 views

Programatically adding/retaining comments within a nested list

Is it possible to convert the following list of strings to computable numbers with the comments preserved? ...
7
votes
4answers
775 views

Removing empty sets from lists

If I had a list, say, names= {"Andy", "Bob", "Carly", "Sandy", "Jeff", "Tim", "Tom", "Zach"} and I decide to pick a characteristic only a certain of them have, ...
7
votes
2answers
246 views

Intersection for lists of numeric data

I know that Intersection is a pattern matching function and will not evaluate list elements to determine if two or more list have equal elements. So my question is, ...
7
votes
2answers
1k views

Get the coordinates from ContourPlot and RegionPlot

How do I get the coordinates from a contour plot I've done in Mathematica? For example, I have a two-variable function f[x, y], for which I can make a contour plot: ...
7
votes
3answers
155 views

Given a list of lists, build a list in which lists with equal first and last elements are grouped together

I have a list of lists, and I'd like to build a new list, in which lists are in the same list if they have the same first and last element. Here's an example. Suppose I have ...
7
votes
2answers
1k views

Finding all partitions of a set

I'm looking for straightforward way to find all the partitions of a set. IntegerPartitions seems to provide a useful start. But then things get a bit complicated. ...
7
votes
2answers
217 views

How can I get the list of dates in the next $n$ years

How can I get the list of all dates from today 21.02.2012 (which is a palindrome) up to say next $n$ years? Then finding the other palindromes are not difficult. I could not find an easy way to ...
7
votes
1answer
296 views

Tuples without self-loop

I have a simple question coincerning the Mathematica function Tuple. Currently, I apply the following code ...
7
votes
3answers
398 views

Filter list based on date

What I would like to do is remove entries from a list of instrument data when it is in maintenance. The maintenance data I have is a series of dates which look like this; ...
7
votes
2answers
319 views

Building a tree

Given a list of word characters, such as this one, I'd like to build a tree, similar to this makeTree function, but with the tree in a different format. So, for an input such as ...
7
votes
1answer
98 views

Why does Rescale performance vary significantly based on the real number values in a list?

I have a list of the form: testList = Table[{Flatten[RandomReal[{-200, 200}, {1, 2}], 1], RandomReal[{-200, 200}, {69, 2}]}, {i, 1, 100}]; And I would like to ...
7
votes
2answers
2k views

Building matrices by attaching vectors (columns) and matrices

Having the need to attach a column to a matrix or to join matrices to make longer rows is an operation that I use very frequently and I find the Join function ideal ...
7
votes
3answers
421 views

How to Gather a list with some elements considered unique

I have a list of the form: list={{0,...},{1,...},{1,...},{0,...},{3,...},{3,...},{0,...},{0,...},{5,...},{5,...},{5,...},{0,...},{5,...},{0,...},...} So when we ...