# Tagged Questions

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

216 views

### What's the most intelligent way to store the information of a selfmade graph?

I have a very long list of element, say $a1,a2, a3$,..., and they are all connected in that each is the child of many parents. E.g. $a74$ is associated with $a2,a55,a71$, and also contains ...
398 views

### Defining a string based sort function

I'm having a bit of trouble figuring out the right Sort syntax to use on a list of lists. Consider the following list: ...
4k views

### Does Mathematica have advanced indexing?

I have two $M \times K$ arrays $L, T$ where I would like to set all the elements in $L$ to zero whenever the corresponding element of $T$ is greater than 15. The ...
5k views

### How can I multiply matrix and vector element wise like Numpy?

I have an $M \times K$ matrix $C$ and a length $K$ vector $v$. I want to form the $M \times K$ matrix $S$ where $s_{ij} = C_{ij}/v_j$. To do this in numpy I simply divide the two objects like this ...
439 views

### Deleting parts of a large list

At present I am running an analysis on economic data. Within the data I was able to identify countries which went through recession. I then calculated for example the average decline rate of GDP ...
380 views

### Are there advantages to using additional arguments of common functions rather than alternative ways of calculating with lists?

(Apologies for the long question title.) One of the interesting, if sometimes confusing, things about Mathematica is that there is always more than one way to do things. Even intermediate users can ...
2k views

### Clustering of space-time data

Below is an example of a gaze sequence I recorded during a 3 seconds display. That is, where the eye was at every millisecond. While we should have 3000 points, we are missing some due to blinking. ...
410 views

### How to efficiently Append a result of an operation on each element of a list to itself

I'm looking for the best function to apply the product of the last two elements of sublist elements to each element: Example: ...
829 views

### Efficiently Visualising Very Large Data Sets (without running out of memory)

I have put a few really hard problems in combinatorics up against Mathematica 8. I'd have to say that it works really well, until you want to view the data. If you look at my question Advanced ...
386 views

### Count number of sublists with a total not greater than a given max

Suppose I have a list of positive integers: data={1, 1, 2, 3, 3, 3, 5, 5, 5, 7, 7, 8, 8, 9, 10, 10, 12, 16, 23} I want to count the number of subsets up to ...
2k views

### What is the right way to rotate an array?

Suppose I have an array, not necessarily square: a = $\left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{array} \right)$ I want to rotate it like one ...
246 views

### Conditional Data Selection, efficiency

Building up on the solution proposed here : Simplifying nested If statements You can find here the data set : allGazes.dat ...
379 views

### How to distinguish between lists and values?

I have a (hopefully small) problem with some numerical integration algorithm, more specifically I want to integrate the imaginary part of a complex valued function, e.g. ...
3k views

### Delete duplicate elements from a list

If a list contains duplicate elements, for example list = {a, 1, 5, 3, 5, x^2, x^2}, how can the duplicate elements be removed? The result would be ...
2k views

### Max of a table/list with indeterminate values

Suppose I have a Table: tab = {1., 2., 3., Indeterminate} When I type Max[tab] I get ...
2k views

### Finding all elements within a certain range in a sorted list

Suppose we have a sorted list of values. Let's use list = Sort@RandomReal[1, 1000000]; for this example. I need a fast function ...
771 views

### How to create a histogram of annual events, such as cherry blossom time

I have calculated blooming and ripening times for a specific variety of plant, based on actual temperature data from over 40 years. I would like to create two histograms on a single axis; one for ...
2k 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 ...
2k views

### How do I find the elements in a list that return the highest value for a function?

Suppose we have a list of values and a function f. I want to find which of the elements maximizes the return value of the function in Mathematica. Let call the ...
1k views

### Splitting up delimited data in lists

One task that I frequently find myself doing in Mathematica is splitting lists into lists of sublists, using specific elements to define the break-points. This is particularly useful with imported ...
246 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 ...
6k views

### Product of elements within a list

Please Consider : list={{5,2,6},{2,8,3}} I need to get the product of all the element within list : As of now I do this : ...
2k views

### How to Derive Tuples Without Replacement

Given a couple of lists like a={1,2,3,4,6} and b={2,3,4,6,9} I can use the built-in Mathematica symbol ...
257 views

### Transform vector with lag

Say I have a vector $Z_n$ with and I want to transform it into another vector using this formula: $X_t=Z_t+0.7Z_{t-2}$ The problem is that I am not quite sure how to get that $t-2$ lag in there. I ...
2k views

### How to sum up subelements of a list of unknown length

I'm simply looking for the {}+{} function for sublist elements of a list: (Parallel sums of elements) ...
423 views

### Finding time-series direction reversal of certain magnitude

I'd like to find the points of a time-series that are a certain distance away (in value, not in time) from the previous maximum, which I consider a reversal. For example, for ...
187 views

### List of different values which have to be formatted differently

I have a large list of values which – for presentation in my LaTeX document – I need to format. For instance: I have calculated growth rates which I now would like to have formatted in the form of: ...
495 views

### Generating a matrix using sublists A and B n times

I want to write a function that generates a square matrix from sublists. My sublists are a = Range[0, x, 0.5]; b = Range[0.25, x + 0.25, 0.5]; Suppose x=2, then I ...
3k views

### How to change step size of ListPlot

The command ListPlot will plot lists with a unit step. Is there any way to change the step size of this?
244 views

2k views

### Most Efficient Way to Calculate the Product of All Items in a List?

Say that I have a list of returns on a financial asset over time and want to know the total compounded return. To get the answer, I need to add 1 to each return and then calculate the product of all ...
2k views

### Selecting a sublist based on Length

If you have a simple list of lists as follows: test = {{1, 2}, {4, 5, 6, 7}, {5, 4, 3}} How do you ask Mathematica to return the sublist of greatest length? ...
534 views

### How to neatly get the sum of symmetric elements in a list?

The task is to compute symmSum[{a, b, c, d, e, f}] (*==> {a+f, b+e, c+d} *) symmSum[{a, b, c, d, e}] (*==> {a+e, b+d, c} *) My clumsy solution is ...
484 views

### How can I remove B -> A from a list if A -> B is in the list?

I have a list of transformations like this: list = {"A" -> "B", "B" -> "A", "C" -> "D"} As this is used to plot an undirected graph with ...
293 views

### Check in a series if there exists adjacent values with less than a certain number of missing values

I'm working with a large number of series of different experiments, where there exist a lot of experiments where there are no entries. I now want to draw a sample where there should exist at least ...
4k views

### How to Delete Elements from List1 appearing in List2?

I'm new to functional programming of Mathematica and trying to remove one list of assorted elements from another. However I only find functions working with the Index rather than the values itself: ...
742 views

### Permutations[Range[12]] produces an error instead of a list

This input: Permutations[Range[12]] Results in this (error) output: ...
1k views

### Selectively Mapping over elements in a List

I am using the following code to easily generate a row of images of all eight planets of our Solar System: ...
183 views

### Bug in LengthWhile?

Bug introduced in 8.0.0 and fixed in 8.0.1 Is this a bug or my MMA went insane or I'm missing something? LengthWhile[Reverse@IntegerDigits[1000], # == 0 &] ...
2k views

### efficient way to count the number of zeros at the (right) end of a very large number

If I want to count the number of zeros at the (right) end of a large number, like $12345!$, I can use something like: Length[Last[Split[IntegerDigits[12345!]]]] ...
954 views

### On generalizing Partition[] (with offsets) to sublists of unequal length

The usual Partition[] function is a very handy little thing: ...
5k views

### Creating a data1 versus data2 plot?

I have a table of data with multiple rows and columns, and I have to make a versus data table using two of these columns. Essentially, I have to set one column of data (column 3) as the y-axis and ...
2k views

### Combination and Permutation

How could I obtain the list of all the groups of 5 numbers taken from Range[12] such that the 2 lists have an empty intersection : ...
2k views

### Finding a subsequence in a list

I have a list and I want to find (in this particular case the first) appearance of a any of some subsequences, of possible different lengths. None of the subsequences is a subsequence of each other. ...
3k views

### How to find rows that have maximum value?

Suppose if I have following list { {10,b,30}, {100,a,40}, {1000,b,10}, {1000,b,70}, {100,b,20}, {10,b,70} } How to find rows that have max value in ...
1k views

### Flatten at a certain level

In an earlier question the brainteasing fourth syntax variant of Flatten was discussed. I see that with ...
2k views

### Why don't * and ^ work as I expected on matrices?

For example, this input... {{1, 2}, {3, 4}}*{{1, 2}, {3, 4}} produces this output... {{1, 4}, {9, 16}} and this input... ...
332 views

### Unexpected behavior from GatherBy in version 7

Bug introduced in 7.0 or earlier and fixed in 8.0.4 or earlier I have come across what appears to be a bug in GatherBy. It appears similar to the problem of ...