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

learn more… | top users | synonyms (5)

1
vote
1answer
35 views

Select on 3D-table along diagonal

I have the following data set on the form (x, y, z) ...
2
votes
1answer
56 views

Table: calculate the intermediate variable but not list them

I want to list {a,c} but c is depend on b, suppose the dependence on ...
14
votes
4answers
395 views

A replacement problem

list = {1, x, 3, x, 4, x, x, 3, 4, 3, x, 2, 3, x, 8, 7}; If there is exactly one integer between two x I want to replace it with y: ...
9
votes
1answer
152 views

How to write this pattern in Pick function

Suppose I have a list called mask composed of 1,2,3,...n. n is different in different situation. Let me takes n=3 for demonstration ...
18
votes
6answers
789 views

Recursively appending elements to a list

In wanting to demonstrate the power of Mathematica, I wanted to show my 11-year-old son how we could validate that his sequences homework was correct. We could generate the next value in sequence in a ...
0
votes
1answer
63 views

How to get all possible combinations of this list? [closed]

I'm trying to get all possible combinations of {0,-1} for a certain length. So let's say I want length 2. Then I want my output to be ...
4
votes
2answers
100 views

Ordering and summing elements of a list based on their indexes

Suppose I have a vector. I assign to every vector index a four-element array, in such a way that index i corresponds to ...
5
votes
0answers
53 views

SimilarityRules for SequenceAlignment of two lists

I am trying to use the SimilarityRules option of SequenceAlignment to customize its output. This works perfectly for strings, ...
2
votes
1answer
38 views

ndsolve interpolatingfunctions not shown/evaluated

Using this technique from Simon, I want to solve a matrix differential equation with a matrix that contains an explicit time-dependence(our variable), but I want to be able to solve this problem for a ...
5
votes
1answer
68 views

ListConvolve with Padding -> Fixed?

The built-in function ImageConvolve takes a Padding option that "specifies what padding to use when extending beyond the ...
6
votes
3answers
202 views

Creating new lists

We have the following list data = {{1,2,3,4,5}, {6,7,8,9,10}, {11,12,13,-1,14}} If I want to create a new list containing the first and the fourth elements of ...
3
votes
1answer
76 views

How to insert into a nested list/association?

Considering following nested structure: ...
2
votes
1answer
44 views

Create array of “positions”

How do I create an array a of generic depth $n+1$, such that exactly: a[[i1]][[i2]]...[in]] = {i1,i2,...,in} ? In words, such ...
3
votes
1answer
110 views

Way to generate all multisets

I have a set $\left\{\{1,2\}, \{3,4\}, \{5,6\}, \{7,8\}\right\}$ (for example) and want to generate all sets of $n$ elements with repetition but without counting the same multiset twice. So I want my ...
4
votes
1answer
61 views

How can I “permute” an ordered pair over all the permutations of say $S_4$?

I want to make an action table of the symmetric group (say $S_4$) acting on the set of unordered pairs of distinct vertices of a square. I have the list of such pairs: ...
4
votes
3answers
220 views

Cleaner way to find a list item within an array.

So I have a list somewhat like this: ...
3
votes
1answer
117 views

Remove leading and trailing zeros from a list

This functions and gives the desired result: {1, 0, 2, 0, 0} /. {x___, 0 ...} :> {x} {1, 0, 2} But with leading zeros it doesn't: ...
0
votes
1answer
76 views

How to plot two lists in the same graph maintaining the scale of the points?

I need to plot two lists of complex numbers in the same graph to show some results, so I'm using the following lists to do that: ...
7
votes
6answers
373 views

How to select sub-lists having at least one element that matches a pattern

This will probably be a very easy question, yet although I did find a relatively similar one, I couldn't use the answers there to solve my problem (I'm still a novice). I'm simulating 10 blocks of ...
2
votes
0answers
66 views

Bug in ListLinePlot[] when Filling up and down?

I'm trying to understand this apparently incorrect Filling behavior in ListLinePlot[]. Evaluating this ...
3
votes
5answers
230 views

Loop over list of lists

Greetengs,im totally new here. I cant fined answer at other simular questions, so i create a new one. I have optical spectra in the following format: ...
3
votes
1answer
114 views

Using Select with Alternatives

I want to select the elements of a list like: ...
3
votes
2answers
115 views

Swap LHS's (or equivalently RHS's) of two rules in a list

Assume I have a list of rules, each of the form $a_i \rightarrow b_i$. What is the best way, for some $i$ and $j$, to swap $a_i$ with $a_j$ (or equivalently, $b_i$ with $b_j$). Currently, I have ...
14
votes
4answers
284 views

Fast Selections Testing on Inequality

Is there a functional idiom for fast selections testing on inequality? For example, finding values from list a & b where the key is less than or equal to a value, in this case 4 or 9. An ...
4
votes
1answer
198 views

Select elements of list

I have a list of lists list={l1,l2,l3,l4,...}; and two elements e1,e2. I want to select from lists ...
0
votes
0answers
86 views

Home Loan Calculator with Variable Interest

I have to make a calculator for a home loan and currently the interest rate is fixed (constant for the entire period of the loan) How can I make the sliders on manipulate so that after each period of ...
2
votes
1answer
57 views

Manipulating and adding elements in a matrix [duplicate]

I have the following j = {{1, 2}, {3, 2}, {5, 4}, {1, 2}, {3, 2}} k = {1, 2, 3, 4, 5} t = SparseArray[j -> k, Max@j {1, 1}] The above creates a 5x5 matrix ...
0
votes
1answer
31 views

Extending the dimension of matrix and manipulating it

I have the following code a={{1,2},{4,3},{3,2}} b={3,4,5}; x=SparseArray[a->Table[0,{i,Length[a]}]] x=SparseArray[a->(Extract[x,a]+b)]; The above code ...
1
vote
6answers
220 views

Is there an existing way to add a comma between elements of a Scan?

Without thinking, I wrote (the equivalent of) this... ...
7
votes
1answer
83 views

fast complement with tolerance between large lists

I want a fast algorithm to get a list of elements to be kicked out of another list. But the kick out criterion is not the exact equivalence, however has a tolerance. Any two elements close enough are ...
13
votes
4answers
361 views

How to evaluate the second argument of Cases only once

I'd like to find a fast but readable way to achieve the following: ...
5
votes
1answer
83 views

SplitBy problem with Associations

Association keys are supposed to be transparent, but in this reduced example SplitBy fails: ...
1
vote
1answer
58 views

Behaviour of RealDigits expected or wrong?

Is this behavior expected or a bug? RealDigits[10304.390456] {{1, 0, 3, 0, 4, 3, 9, 0, 4, 5, 5, 9, 9, 9, 9, 9}, 5} when I ...
3
votes
1answer
147 views

Animating N points

So I'm trying to create an animation of N interacting particles in two dimensions confined in a box. Generating the data is fine and it's being stored in a text file with two columns for each ...
2
votes
1answer
49 views

Path with no dependence violations

I am guessing this will be a duplicate(it seems like a common task), but I obviously can't find the right page. I have a directed graph showing dependencies, and I want to list the vertices in an ...
12
votes
3answers
504 views

Map a function of several arguments

I have three lists, e.g. list1 = {{a,b,...}}; list2 = {{1,2},{3,4},...}; list3 = {{x,y},{z,w},...}; and a function ...
10
votes
6answers
441 views

Unique Element in List

I have a list a, and want to find out whether there is a unique element in the list. For instance a={x,y,z,y,x} has an unique ...
3
votes
2answers
109 views

Given a list of positions in a matrix, get elements within radius r

I have a n x n binary matrix like SeedRandom[1]; mat = RandomInteger[1, {9, 9}]; MatrixForm[mat] I want to create ...
3
votes
2answers
63 views

Access all the elements of matrix from a list

I have a list of lists e.g: c=Table[i+j,{i,5},{j,5}] and a={1,2,3};b={3,2,5}; Now I want to access the elements of ...
3
votes
1answer
66 views

How can I extract parts of a mixed list? [closed]

I have the following list: lst = { {1, {{"abc", "bcd"}, {"cd", "efg", "fghi"}, {"g"}}}, {2, {{"abcd"}, {"bc", "cdef"}, {"defgh"}}} }; By using ...
19
votes
2answers
443 views

Upper bound “Vicious nearest neighbour” algorithm suggestions

I am asking a question based on this question from the sister site MSE. In an effort to make this a self-contained question, I include the fiorst documented posing of the problem by Robert Abilock in ...
3
votes
4answers
156 views

Filtering the close values from the list?

I found some difficulty to flatten the data. Let's say we have a list such that, list={-0.0223, -0.0199, -0.0195, -0.0159, -0.0159, -0.0122, -0.0126} You can ...
2
votes
1answer
58 views

Change some elements at the second level of a list based on some conditions

I need to change some elements at the second level of a list based on some conditions. I have the following list of objects of the same type: ...
10
votes
1answer
202 views

Why does Nearest not support Sqrt?

Bug introduced in 10.0.2 and fixed in 10.3.0 Simple examples with two points nf1=Nearest[{{0, 0}, {Sqrt[2], Sqrt[2]}}] nf1[{0, 0}, {All, 2.1}] gives ...
0
votes
2answers
72 views

Select elements from a list

I need to transform millisecond data of trades of a certain stock to (approximately) minute data. The data is of the form ...
1
vote
2answers
86 views

Pick the maximum element of each nested list [closed]

Suppose that I have a list with nested lists, where each nested list contain entries consisting in 3 columns: ...
0
votes
2answers
97 views

“renormalising” a list [closed]

I am looking for the most effective way to solve the following problem: EDITED (for clarification): I have a large table MyTable, say $200$ columns and $10^5$ ...
5
votes
1answer
242 views

How can I add a mesh over this?

How can I add a mesh over the following 3D plot? ...
1
vote
6answers
191 views

A list of alternating interval between its components

How can I create a list of the following numbers in a table automatically? list={3 π/10, 7 π/10, 13 π/10, 17 π/10, 23 π/10, 27 π/10, 33π/10, 37π/10,....} I ...
6
votes
2answers
154 views

Grouping the list of numbers that have common.

I am working on some simple problem. It is like puzzle.. Let's say I have some list input={{1,1},{1,2},{1,3},{2,3},{3,3},{4,4}} Which means 1 can go and back to ...