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

learn more… | top users | synonyms (3)

3
votes
4answers
197 views

Finding the location of the last day of the month in a list of dates

My question differs from earlier questions about getting the eom dates from a list; I want to get the position of those dates so I can get the corresponding values from other lists. My problem seems ...
7
votes
5answers
300 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 ...
1
vote
0answers
34 views

How do I define a tensor from another tensor with summations? [duplicate]

Let's say we have a rank 2 tensor $g_{ij}$. This is basically a list with a Depth of 2. Now I'd like to calculate another tensor ...
3
votes
5answers
396 views

Minimum in a nested list [duplicate]

I have a nested list of {x,y,z} and I want to find out the values of x and y where z is minimum. I can write a nested For loop and do it ...
4
votes
3answers
172 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}] ...
7
votes
1answer
239 views

Visualize a tree structure using TreeGraph

I have a code that generates a tree of graphics objects. The structure can be visualized like this, with each Rule constituting a parent child relationship: ...
4
votes
1answer
204 views

replace items in a list with items in a another list

Suppose I have a list A={x1,x2,x3}, a list B={3,4,5}, and a function f[x]=x1+x2+x3. Is there ...
9
votes
2answers
442 views

Rearranging a List

I am trying to rearrange/sort a list i.e. {{1,2},{10,140},{43,10},{1,140},{43,2}} into ...
0
votes
0answers
44 views

Arithmetic operations on columns [duplicate]

I have imported a file, data.txt, then plotted columns 2 and 3 as function of column 1 using the commands below. ...
5
votes
2answers
671 views

How to optimally solve and generalize this Conway's Game of Life puzzle

I tried solving this using mma. I am aware of this command - Cellular automata. But i don't want to use that coz then there is no challenge. So below is how i did it and my question is can this be ...
0
votes
2answers
91 views

List of lengths of runs of elements

I have a list where a few distinct numbers occur, e.g. {41, 41, 41, 1009, 41, 41, 41, 41, 41, 41, 41, 1009, 41, 41, 41} I want to extract the information of how ...
1
vote
2answers
148 views

Generating list of coordinates in $\mathbb{Z}^n$ given by set of inequalities

I am trying to generate list of coordinates that forms a subset in the integer lattice $\mathbb{Z}^n$. This set is given by set of inequalities. Right now, I am using the following: ...
1
vote
2answers
146 views

Discretizing data using quantiles in Mathematica

I am trying to discretize a long array of real numbers into a uniformly distributed integer array. To do this I am identifying the quantile where each real value sits and writing it out to the output ...
9
votes
4answers
570 views

Find positions of items in a list based on neighbours

How can I select items from a list where the selection criterion depends on the neighbouring items? For example select all indices where a change has occurred with respect to the previous element in ...
0
votes
0answers
24 views

Create a (maybe nested) list of nminimize solutions in a loop [duplicate]

I'm a total newbie in mathematica, so need some help. I understand that my question is about basics, but i couldn't find the answer in docs, google and here. Here is what i'm trying to do. ...
1
vote
2answers
79 views

Sorting lists with elements that are identical [closed]

How can I sort the following list: list={{1498, 1495}, {1498, 1733}, {1553, 1552}, {1552, 1495}, {1733,1776}, {1776, 1553}}; such that the next group contains ...
5
votes
2answers
295 views

How to create this list more elegantly

There is list containing some $(i,j)$ values of indices. Now i want to create a matrix of dimension n $\times$ m whose entries are 1 for the indices corresponding to the given list otherwise its ...
2
votes
2answers
135 views

Generating an editable table that can be used as input

Say I have a number $n_{max}$. I want a command to generate a table like 1 1 2 2 3 3 4 4 ... nmax nmax where the second column is editable, and this table can be ...
0
votes
1answer
251 views

Remove list elements that contain NaN Symbol [duplicate]

I have a long list of lists ...similar to g = {{1,2,3},{4,2,7}, .....{1.2,9}}. Occasionally, g contains elements like ...
1
vote
3answers
86 views
0
votes
3answers
105 views

string to complex number

Consider the following list MyList= {-0.0000396, -0.0000187167, "0.10259130990561813-0.0677132394802944i"} Head /@ MyList (* -> {Real, Real, String} *) In ...
10
votes
3answers
559 views

Fastest way to check for List membership

I have a set of say 100 numbers {1,3,7,11,19,...3971}. All elements are previously determined. I want to check whether ...
5
votes
3answers
274 views

Question about Map and Total

Suppose I have a list and I want to generate a new list, such that $$ NewList[index] = \sum_{index \neq j}^{NumOfElts} \frac {1}{ \lvert OldList[index]-OldList[j] \rvert ^2 } $$ Can I do it using ...
0
votes
1answer
65 views

Produce a 1-dimensional list of all unique matrix elements

We have some symbolic matrix m, e.g. m={{1, x, 4 x + y},{0, x y + 4x, 4x},{7 x, x, 4x + x y}} and we want to produce as output a list of all the unique elements ...
0
votes
2answers
123 views

Result of NIntegrate ploting to list

I've been working on a project where I need to make two Plots. Those plots are of the form: ...
1
vote
1answer
221 views

Partitioning time series data in sublists by their duration

I would like to do calculations on irregularly sampled time series data at intervals - for example on an hourly basis - rather than over the whole time series. The entire dataset is split up by time ...
14
votes
6answers
1k views

Shuffle product of two lists

I want to do the following: I have two lists {a_1,...a_n}, {b_1,...,b_n} and I would like to build now all shuffles out of this. This means all unions of these ...
2
votes
1answer
186 views

What is an elegant way to aggregate two cash flows

When modeling a swap contract a common operation is to sum up two cash flows producing a resulting cashflow with netted amounts in the highest granularity of the two initial cash flows. What is a ...
0
votes
2answers
105 views

Handling output that was returned unevaluated from a function

When evaluating functions, including those described in this post, how do Mathematica users handle values returned from a function that are unevaluated? For example (based on 1): ...
1
vote
2answers
257 views

Mapping functions over multiple lists

I am not sure if this is a duplicate. Spent some time looking over list-manip questions. I’d like to know the Quickest Way to achieve the following Mapping of a function over multiple lists. ...
2
votes
2answers
202 views

Replacing values above a threshold with 1 [duplicate]

I have a list with some values and I want to replace a value which is greater than 1 with 1 otherwise keep the value. In this case 10562: ...
7
votes
5answers
321 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 ...
1
vote
1answer
86 views

Experiment with TagSetDelayed involving Part

Reading Associating Definitions With Different Symbols, I was intrigued by this: You can think of upvalues as a way to implement certain aspects of object-oriented programming. A symbol like ...
6
votes
7answers
1k views

How to select all elements above the main diagonal of matrix?

How to select all elements above the main diagonal of matrix? I need to create a list of them.
2
votes
2answers
116 views

Elegant way to rearrange year/date table into time series/values

I often have data in the form of YEAR JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC 1950 -1.022 -1.146 -1.289 -1.058 -1.419 -1.36 -1.334 -1.05 -0.578 -0.395 -1.151 -1.248 1951 ...
2
votes
2answers
162 views

How can I thread lists of different sizes?

What I need is the equivalent of Maple's zip(+, A, B, 0). Sure I can get it with: ...
1
vote
1answer
172 views

Selecting every last element of a nested list

I couldn't find a similar question so I decided to ask this one. I have a nested list with many sublists of equal length. To make things easier let's say it's like that: ...
13
votes
4answers
2k views

Semi prime numbers

The high school textbook I am using has the example of semi-prime numbers. They wanted students to find (by "perspiration") all the semi-prime numbers less than $50$ (for a question on set theory). ...
2
votes
1answer
84 views

Intersection does not take list of lists

The function Intersection takes a number of lists (sets) and finds their intersection. However, the precise input is ...
1
vote
2answers
163 views

Sorting lists element by element [duplicate]

I have a problem regarding list sorting. Let's say I have a list of lists obtained using Subsets[], of the form ...
0
votes
2answers
106 views

Specifying an array that may have an unknown number of entries [duplicate]

Say I'm running some process of unknown duration, and during the process, I need to periodically record the state of some variable. If we knew exactly how long the process took, we could simply ...
4
votes
3answers
343 views

Fast method for combining two lists

I have two lists, v1 and v2. Each element of the lists may be positive or negative. I want to create a list ...
2
votes
7answers
300 views

How to replace plus sign by comma

I want to replace plus by comma and the order of numbers in the list should be in increasing order. Example: a1 + a10 + a11 + a13 + a2 + a27 + a28 In this ...
1
vote
1answer
57 views

Evaluating the tensor product many times for a given list

I need to evaluate the tensor product 10 times in a given list( {g,e,r}) Here I have evaluated for 3 times... ...
0
votes
1answer
2k views

Table - find index of the maximum element [duplicate]

Let's suppose that I have table t = {1.23, 3.4, 10, 34, 1.78, 0.98, 12.56}. To take the biggest element I can use Max[t] ...
1
vote
1answer
365 views

ListPlot doesn't shows all points [closed]

I have a table: p1 = Table[(Binomial[2000, k]*StirlingS2[1386, k]*k!)/(2000^1386), {k, 1, 1386, 1}]; I used ListPlot[p1] ...
2
votes
3answers
149 views

Counting instances where the two identical characters are at the same positions in two strings

Let $s_a$ and $s_b$ be two strings over a $q$-ary alphabet. For each character $(c_1,...c_q)$ in the alphabet, I'd like to return a pair of values $(r,k)$ where $r$ represents the count for the ...
0
votes
1answer
51 views

Error about limit MaxExtraPrecision

After my evaluations I have an error: N::meprec: Internal precision limit $MaxExtraPrecision=50. reached while evaluating ... ...
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 ...