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

learn more… | top users | synonyms (4)

4
votes
0answers
239 views

Strange behavior of undocumented RawArray and ArrayObject expressions

I discovered several strange results and inconsistencies while trying to understand what undocumented RawArray and ArrayObject ...
3
votes
5answers
1k views

Find the slope between adjacent points in a list

I have a list of two dimensional points that are ordered by their x-coordinate. I would like to calculate the slope between all adjacent points. I'm familiar with the use of pure functions in Sort ...
3
votes
8answers
256 views

How Do I Perform Simple Operations On The Elements of a Table?

I have been using the function HistogramList to generate frequency tables off a data set. The code looks like this: ...
3
votes
7answers
381 views

Concise way to generate multiset lists

I wrote the following to generate a multiset with the same number of items over a fixed range: ConstantArray[#, 3]& /@ Range[9] // Flatten ...
3
votes
4answers
340 views

Mapping over the last level of a list, or equivalent operations

I would like to style each element of my list using Style. But when I try ...
3
votes
6answers
562 views

How to smooth the noise

This is a sample data ...
3
votes
5answers
295 views

Function involving For loop

I've written the following function (the code includes the output): ...
3
votes
3answers
661 views

Problem with Union and Intersection

Consider the following: list={{a,b,c},{c,d,e},{d,e,f},...{x_,y_,z_}}; I would like to apply Union on the elements of the list ...
3
votes
3answers
188 views
3
votes
5answers
443 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 ...
3
votes
6answers
345 views

How can I construct a distance table?

I have a list of city names (of arbitrary length), f.e. c = {"BAL", "NYC", "LAS", "AUS"}; and the distances between them : ...
3
votes
4answers
371 views

Find the longest constant sublist

Given a list list = {1,2,2,2,2,5,1,3,2,6,6,6,6,6,6,6,6,6,6,6,10,-3}; how to find the longest constant sublist (or equivalently the element and the number of ...
3
votes
2answers
219 views

How to replace Do loops by Inner

I need to replace Do loops by something else because it takes forever with big programs. I have been hinted towards Inner, but ...
3
votes
4answers
981 views

Extract function arguments

Is there a way to extract the arguments of a function? Consider the following example: I have this sum ...
3
votes
3answers
2k 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?
3
votes
3answers
330 views

Incrementing a nested list element

I've been wanting to increment a nested list element of which I know the "coordinates". I thought of the following procedure, using Apply with Part. ...
3
votes
2answers
3k views

Calculating the distance between the coordinates in a list

I have a list of coordinates {{A[9, 4, 7], 0.0395174}, {A[1, 5, 0], 0.0163797}, {A[0, 7, 2], 0.0577425}, {A[2, 7, 5], 1.01313}} I want to find the distance ...
3
votes
4answers
225 views

Replace all symbols in a matrix with their numbered forms

I have a matrix made mostly from "x" with a few 0's thrown in: ...
3
votes
4answers
563 views

More elegant way

I read ReplaceOrRemoveInvalidOrMissingData Mathematica documentation, and I tried to apply the same approach to my dataset. I've got two problems, but one is only a style problem! There is one more ...
3
votes
2answers
173 views

Sequence and boolean And

I'm trying to figure out if a calculation result it's a valid result. As it return a matrix, I need to test that every element it's a number, so I thought this could work... ...
3
votes
7answers
208 views

List creation/manipulation

I'd like to a create a list from A = {{a}, {b}, {c}} by taking each elements n times in the following form: ...
3
votes
4answers
372 views

How to apply a function of several arguments to a list?

I have a list of triplets: list = {{1, 3, 5}, {4, 5, 1}, {4, 9, 2}} How can I apply a function f to the last element of each triplet when f the last and ...
3
votes
6answers
167 views

Change sublist based on position

Supposed that: list = {2, 3, 5, 7, 9}; sublist = {{3, 3, 5}, {2, 2, 2, 7, 9}}; I want to change each sublist in sublist as following: Find the positions of ...
3
votes
4answers
235 views

Test whether date is in a certain period

I have one table which contains time periods ("start" and "end") and a "type" for every ...
3
votes
7answers
581 views

Remove elements at certain positions from all sub-lists?

Consider a big list where all the inner lists length's are the same list = {{x1, y1, z1, t1}, {x2, y2, z2, t2}, {x3, y3, z3, t3}, ...}; elementNo = {4, 3, 2}; ...
3
votes
3answers
705 views

Sum of Multinomial Coefficients

Basically, I want to write a function to compute the following sum $f(m,L):=\sum_{0\leq k_1,\cdots, k_n\leq m} \binom{m}{k_1,k_2,\cdots k_n}$ and $\mathrm{supp}(k)=L \subseteq \left \{ 1,...,n \right ...
3
votes
3answers
216 views

Plot sublists as different colors

I have one big list with many sublists inside. All sublists consist of three numbers. For example: ...
3
votes
3answers
251 views

Logical AND operation over several comparisons

Let x and y be arrays defined as Array[x, m], Array[y,n] respectively. How to generate the following function of $x$ and $y$ for variable $k$: ...
3
votes
2answers
1k views

For loop with steps other than 1

I would like to do a For loop with a jump 2*Pi instead of 1. For[j = 0, j <= nmax, (incr = 2 Pi), ...] Actually what I want to do is ...
3
votes
2answers
80 views

Output matrix with common elements

Given lists of lists like a and b, I want to obtain an output like c. a = {{2, 1, 0}, {1, 2, 1}}; b = {{2, 2, 0}, { 2, 2, 1}}; c = {{2, 0, 0}, {0, 2, 1}} If ...
3
votes
3answers
189 views

How to Update 2D List based on a binary array

I have 3 lists: numbers = {{1, 2}, {3, 4}, {5, 6}}; toUpdate = {{1, 0}, {0, 0}, {1, 1}}; newValues = {{10, 20}, {30, 40}, {50,60}}; I have to update the list ...
3
votes
3answers
168 views

Finding the first position in a list that is over a certain value

Let's say I have the following list: L = {2,4,6,8,10} How can I get Mathematica to find the index position of the first value in the list that is over 4 (6 in ...
3
votes
5answers
344 views

How to extract strings from the list with an additional condition on previous elements?

There are a long list of strings $s$ and two lists of substrings $s1$ and $s2$. I want to take all elements of $s$ which contain a substring from $s2$ and such that before it on no more than $n$ ...
3
votes
3answers
115 views

Calculating expected value from paired values and weights

I'm very new to Mathematica. I just need a quick solution on how to multiply x with y when a data set is given as ...
3
votes
4answers
127 views

How to combine the elements of two lists using a user-specified function

I have two lists of integers. From these lists I want to produce a list where each element is a fraction derived from a corresponding pair of elements in the original lists, the smaller integer of the ...
3
votes
3answers
156 views

Cases or Select for catching elements in a list?

I have A list that contains sublists like that: ...
3
votes
2answers
459 views

Why does a certain CSV file import properly into LibreOffice but not into Mathematica 10.0?

I'm working on a project involving data manipulation and it involves working with CSV files. I know that the files are properly formatted as when I import them into LibreOffice, all of the columns ...
3
votes
2answers
259 views

Weird behavior when changing parts of matrix

I have this matrix: mat = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {16, 17, 18, 19, 20}, {21, 22, 23, 24, 25}}; and here are its second row ...
3
votes
2answers
329 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: ...
3
votes
3answers
149 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 ...
3
votes
2answers
882 views

Adding and subtracting from elements in a list

I'm trying to solve an aparently simple problem. Given a list of length n, {a1,b1,c1,d1...} I want to perform two simple ...
3
votes
5answers
595 views

How to combine some elements of a list?

In order to simplify my expression, I face a list manipulation problem. For example, given the input list ...
3
votes
2answers
113 views

Nested List Product

I want to apply Times on the elements of a list such that: ...
3
votes
3answers
476 views

How to pull scalars out of a function that should act on lists?

Suppose I have A = a vecA B = b vecB where a and b are supposed to be arbitrary scalars ...
3
votes
3answers
321 views

Combining heads of lists so that you can create a nested list from two sublists

I have a list such as list = {1,4,3,4,6,3,1,2,3,4 ... } and a range, say, range = Range[20000]. I want to obtain the following ...
3
votes
3answers
157 views

Move element inside a list

I need to change the position of a single element in a list. Example: I start with: {a,b,c,d,e,f} I want to move the a before ...
3
votes
3answers
83 views

Identifying locations of entries in an array

If I’ve got a big array displayed in Mathematica, is there a way for me to select a particular location on the screen and have Mathematica tell me “You’ve selected the entry in row 137 and column 92” ...
3
votes
3answers
198 views

Pare down list recursively

What is the best way to pare down a list whereby the $n$th number is removed from the list recursively? This ...
3
votes
2answers
110 views

Matrix of given size with unspecified elements

I want to generate a Matrix of given size whose elements are not specified I can use Array[a, {3, 2}] to get ...
3
votes
5answers
543 views

Randomly selecting and reinserting a subset of elements in a list

This question is similar to my other question: How do I randomly select 'k' positions in a list and shuffle their respective elements without effecting the other elements? Imagine first a ...