# Questions tagged [list-manipulation]

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

9,496 questions
Filter by
Sorted by
Tagged with
70 views

### How would you perform a simple operation on two adjacent elements of a list?

I have an arbitrary list of elements: list = {a, b, c, d, e, f} How would I produce: ...
99 views

### Bin edges from BinCounts

I'm working with a set of data binning values. I'm using bincount and binlists to find bins that meet a certain criteria and then testing a list to see which are within one of those bins. This list of ...
489 views

### Deleting duplicates after n-occurrences

As a generalization of DeleteDuplicates, I want to delete duplicates from a list, but only after n number of duplicates. Say, <...
306 views

### Finding equal values in a list

Is there a way to take equal elements out of a list and their position??? An example can be ...
101 views

### Rows within a norm

Is there a way to take a matrix and select the rows (or columns) with norm lesser than a certain amount max. Thanks
1 vote
50 views

### Incrementing Numbers

I want to take a prime number p0 = 3, add 2 to it to get a new number p1 = 5, then add four to p1 to get p2, then add 6 to p2 to get p3, etc for a total of 50 times. How do I do that and place my ...
143 views

How can one do a fast sparse tensor addition? Below, I have the following code: We first generate 3 random sparse 1000x1000x1000 tensors with 10^6 entries each. Then, I want to add them. But the usual ...
189 views

### Fill space between two BezierCurves with random points

I asked a question about filling the space between two curves (Sin and Cos) with random points and the answer I received does ...
491 views

### How to verify whether list A contains all elements of list B?

I want to determine whether a list A contains all the elements in the list B (including duplicate elements). For example, for <...
290 views

### Partition sublists of a list

Let's say I have the following list: l1={{2015, 5, 6, 13692}, {2015, 5, 7, 13715}, {2015, 5, 10, 13274}, {2015, 5, 11, 13581}, {2015, 5, 12, 13609}}; How is ...
176 views

### How to remove sublists whose difference of two elements is either 1 or 11?

I want to create a list of 3-element subsets of $\{1,2,\cdots,12\}$ where no two elements in each subset can have difference of 1 or 11. I am trying to solve the following: Find the number of all ...
881 views

### Conditionally replace rows in lists

I have a sequence of matrices/lists ...
614 views

### Replace multiple elements at different positions

I have a list a = {0, 0, 0, 0, 0}; and now I would like to make only those elements 100 at the positions in pu = {1,4,5}; So I ...
99 views

### How to use Cases to delete specific lists from a nested list

To simplify things, let's say that I have a list: aList = {{1,2,3,4},{2,2,6,6},{6,9,8,7},{6,6,6,3}} and I want to use Cases to ...
729 views

### Applying a function to every item in a column of a matrix

A problem that arises more often than I care for is that I want to modify specific elements nested lists. Examples may be wanting to add 1 to the second value, get ...
273 views

### How to remove sublists whose last digit is odd?

I want to remove any sub-lists whose last digit is odd. My attempt below does not look elegant because I convert each sub-list of digits to a number first and then remove the odd numbers. Question How ...
138 views

### How to rearrange sublists based upon the element in the first position?

If I have the following code: ...
803 views

212 views

### List operations: how to combine two lists (pattern given)?

Two lists (matrixes) are given: a = {{x1, y1}, {x2, y2}, {x3, y3}}; b = {{u1, v1}, {u2, v2}, {u3, v3}}; Expected return: ...
385 views

### Take elements from a list based on two criteria

I am trying to take elements from a list of tuples using 2 criteria. An example of the list is: list={{-1, -1}, {-1, 1}, {1, 1}, {1, -1}, {1, (1 + I)/Sqrt[2]}} ...
486 views

### How to apply a function to one part while keeping the rest?

I have a list and want to apply a function just on the second Part and keep the rest. t1 = Table[{k, 2^k + 1}, {k, 2, 7}] ...
222 views

### Question on using Array

I could do vars3d = Array[Through[{x, y, z}@#] &, 5] to obtain ...
398 views

### When applying (@@) a function to a list of potential arguments, how can Slot be used to take the last argument?

I wouldn't be surprised if the title question is confusing, so I'll try to elaborate by way of example. Consider the list ...
247 views

### How do I replace specific sequences of a sublist without changing the level of the list?

Suppose I have a list of multiple sublists: testlist={{1,1,1,0,0,0,1,1,1,0,1,1},{1,0,0,1,1,1,1,0,1,1,1,0}} I want to replace given sequences without creating new ...
227 views

### How do you reorder a sublist of strings, within a list?

I have a list that looks like this: ...
149 views

### Create a list that always ends with two 1's but starts with a variable amount of 0's

I want to create a variable list like this: {0, 0, ..., 0, 0, 1, 1} This list would grow list this, starting with no 0's, but then gaining more 0's to the left the ...
1 vote
66 views

### Sum of disjoint product of sets [closed]

If we have the following sets and we need to apply the Sum of disjoint product property to them, as in the following example: Take: $$P_1=\{x_1 x_4\}$$ $$P_2=\{x_2 x_5\}$$ $$P_3=\{x_1 x_3 x_5\}$$ <...
368 views

### How to pass arguments to the list of functions?

Suppose I have a list of functions: functions = {f, g, h, ...} And all of those functions are in form of f[x_ , y_]. For ...
140 views

### Combine list elements preceding a specific element

Consider the following list: {"END", "END", "a", "b", "END", "p", "q", "END", "t", "END"} I want to combine elements that precede the marker element ...
166 views

### Map substitution of variable in expression

If I have an expression involving a variable x, like 2x+1, and I have a list of different possible ...
216 views

### Display Table output as a grid of points

I want to create a Grid or Plot (or equivalent) from the following Table: ...
2k views

### Subtracting from a specific column

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 ...
197 views

### How can I add or remove the element in the sub-lists, whose length are different?

If there are lists with different lengths of sublists like below, ...
107 views

### Conditionally extracting data from long lists

I need to make a fit on a small part of my data list. To do so I need to extract data setting a condition. Example: From the list below I would like to create a new list that contains only data whose ...
696 views

### Simple way to convert expression to a list?

I know that I can convert an expression to list by List @@ expr But this does not work if expr is atomic, e.g., ...
194 views

### How do you apply "Pick" to multiple sublists?

I have the following list: lis1={{{A3,T3},{A3,T4}},{{A3,T3}},{{A3,T3},{A4,T4},{A3,T1}}} Which is also accompanied by an ...
186 views

### How do you take position "x" in multiple sublists to make a new list?

this is a rather rudimentary question, but I was wondering if there are more efficient ways to do the following: dd = {{{12, 3, 5}, {14, 10, 11}}, {{15, 76, 65}}} ...
271 views

### Threading a list of functions over a list of arguments

I want to produce {Foo[a,b, c], Goo[a, b, c], Hoo[a, b, c]}. However my attempt below ...