# Questions tagged [list-manipulation]

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

6,406 questions
Filter by
Sorted by
Tagged with
78 views

### correct use of the command FindInstance

I have tried to solve this system for numbers that go from 1 to 10 non-repeated integers, this occurs to me ...
30 views

### Counting the number of occurrences of specific values in a list in specific intervals

If the variable "digits" contains 10,000 digits from 0 to 9. How can the number of occurrences of 1s and 2s be counted in every 1000 digit intervals, that is to say the number of 1s and 2s ...
4k views

### Finding the period of an array of integers

A simple array of integers is given. The problem is to detect if a pattern is repeatedly occurring in the array, and find the length of that pattern. For example, for ...
56 views

### Building a matrix from the columns of others

A is a n x m matrix, B is a matrix p x m, I wish to build C from appending the ith column of A and ith column of B, for all i ...
70 views

### Using DateListPlot without connecting dots

I have a list of values like this: When I plot this data using DateListPlot[data] I get a plot connecting the individual points such as: My question are: How can ...
56 views

### Use Cases with empty cells in the list

I work with a complex dataset. The most simple form of this list looks like: dat1 = {{a, b, c, {}}, {d, e, f, {1}}, {h, i, j, {2}}} I want to select the nested {} ...
97 views

### Find rules for the similar “Conway's Game of Life”, and initial input on an 11x11 torus board. Descripted on the “Puzzel Chalenge IBM May”2020"

I solved on May 2020 this using mma . I am aware of this command - Cellular automata. But I can't use it on this challenge, because there's no concept of "Torus" in the CellularAutomaton . ...
1k views

### Find second largest elements in list

Given a list: lis = {37.21, 37.21, 37.2, 44, 44, 44, 101, 101} What is a simple way to extract the second largest elements? ...
135 views

### Fast way to count distinct pairs of integers

I have a association list, S, whose size is about 5*10^4. I also have a function F which takes in ordered pairs of elements from S, and spits out ordered pairs of integers. There is some amount of ...
26 views

### Thread::tdlen: Objects of unequal length in {{a,b,e},{c,d,f}} {x,y,z} cannot be combined

When I do the Times operation among list like this {{a, b, e}, {c, d, f}}*{x, y, z}, the error message is given as Thread::tdlen: Objects of unequal length in ...
55 views

### Finding points located in a specific locations of a 3D objects

I have the following list of points in 3D and would like to find the points which are located on the lower edge of the object and on (or closest distance to) the X-Y or Y-Z plane of the symmetry. (...
53 views

### How to manipulate solution outputs that appear in a list? [closed]

I have a list {E, {p, ϕ}}, and I need values E, p, and ϕ ...
158 views

Given t1 = {1, Sqrt, Sqrt, 2, Sqrt, Sqrt, Sqrt, 2 Sqrt, 3, Sqrt, Sqrt, 2 Sqrt}; I just want to get all radicands, which would yield <...
31 views

### Exporting Nodal Surfaces/Minimal Surfaces as any 3D source (obj,stl,mb…)

I have been trying to export the surfaces that I gathered in the Wolfram Mathematica application, So is there any way to export surface this to Maya,Cinema 4D, Rhino , or any 3D environment for 3D ...
97 views

### Finding lower boundary of a 3D object in list format

I have the following point list and would like to find the points located in the lower boundary of the 3D object (It is part of a body torso). https://pastebin.com/L12n0Gfr I am using the following ...
56 views

### Find a sublist with closest X and Y to a specific point in 3D

I have the following list of points and would like to know how I can find the sublist (i.e. point) which has a closest X and Y value to the X and Y value of a specific point (e.g here b1 ={{-20.6105, -...
729 views

### Partition list into $n$ sublists

Is there an inbuilt function/option or an elegant composition of functions for partitioning a list into exactly $n$ sublists? I played around with Partition and its ...
41 views

### How to change a list of values into variables? [closed]

I have a list {E, {p, ϕ}}, and I need values E, p, and ϕ ...
56 views

### Plot 2D into discrete 3D [closed]

I want to do a 3D plot of this functiony[x_, r_] = -Tan[r] x where I get a set of lines evenly distributed on the r axis, with a discrete distribution. This is what ...
291 views

### Select lists where last elements are identical

Given the following list t1 = {{5, 5, 50}, {6, 1, 37}, {6, 2, 40}, {6, 3, 45}, {7, 4, 65}, {7, 6, 85}, {8, 1, 65}, {6, 6, 72}, {7, 1, 50}}; I want to find those ...
30 views

### Replacing a submatrix of a matrix

Minding the fact that In:= {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}[[1 ;; 2, 1 ;; 2]] Out= {{1, 2}, {4, 5}} is the upper left submatrix. I would like to do the ...
36 views

### Binning of numerical 2d function [closed]

I have a set of data {x_i,y_i,z_i} organized as 3-member sublists in a large (~4000 sublists) list. The z_i are functions of (x_i,y_i): z_i = f(x_i,y_i), but the function f is known only numerically. ...
294 views

### How to drop points that don't lie in a line

I have some data like: ...
40 views

### Substituting values from an association thread into a table of expressions

I have asked a question here. Yet I am trying to do the same procedure with AssociationThread Suppose I have the following function which is a normal distribution: <...
45 views

### Substituting elements of lists into an expression

Suppose I have the following lists, as = {1, 2, 3, 4}; bs = {10, 20, 30, 40}; and the following expression: ...
77 views

I am trying to use Thread to apply a function involving RandomReal but it does not work as I expected. If I have the function <...
85 views

### How to use Quartiles to work the same as TI-83 calculator? [closed]

The statistics book I am using defines quartiles the same as Method 1 explained in wikipedia. Use the median to divide the ordered data set into two-halves. If there is an odd number of data points ...
348 views

### How to classify an ordered ascending {0, 5, 5, 10, 19, 22, 23} into several classes {{0,9},{10,19}, …}?

I attempted to classify an increasingly ordered list into several classes to make frequency distribution table. I am faced with a difficulty to nest two pure functions: one for ...
52 views

### How do we list all points in the Middle $3/7$-th Cantor Set?

Suppose we were to list all points in the $3/7$th Middle Cantor set where we first remove $3/7$th of $[0,1]$: $$[0,1/7]\cup[2/7,3/7]\cup[4/7,5/7]\cup[6/7,1]$$ then $3/7$th of remaining intervals, $3/7$...
86 views

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

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

### How to program a situation like the following in mathematics and generalize the process to other configurations?

Distribute the numbers from 1 to 10(view image) so that the sum of each row and each column is the same and a) the maximum possible b) the minimum possible (I put it from 1 to 10 for ease) I know it ...
83 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}}} ...
36 views

### Precisión of the numbers inside a list

I'm trying to become a List like this list={1.34,2.64,5.098,6.432} in a list where the numbers have precision of one digit, like this ...
3k 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 ...
153 views

### Operation on the first element of list only

If I have the following list: ...
2k 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 ...
325 views

### How to find the smallest position of an element of an ascending list {1,4,10,12,20} such that the element is not less than 11?

Assume I have an ordered, ascending list {1,4,10,12,20}. I want to find the smallest position of an element of the list such that the element is not less than 11? ...
59 views

### How to select parts of a (non)function

I have a set of points ...
2k views

### All possible topological orderings of a graph

TopologicalSort[] returns one of many unique orderings. From wikipedia: if a topological sort does not form a Hamiltonian path, the DAG will have two or more valid ...
83 views

### Selecting elements of a list based on specific elements of their sublist

I have the following list ...
63 views

### How can I iteratively add elements to a list

Basically I want to make a histogram with a list of dates by using DateHistogram[]. However I have the data of the dates in nested list format, with elements like ...
106 views

### How to get elements corresponding to UpperTriangularize

For a generally non-square matrix M, I want the upper triangle that include the diagonal entries. Specifically, this is implemented via UpperTriangularize: ...
97 views

### How to permute elements in a list

I am attempting to decrypt a ciphertext. I split the cipher into blocks of five, and now I want to permute each individual block. My goal is to be able to permute each individual block by the same ...
921 views

### Is there any better way to create {a, a, a, b, b, b, b, b, c, c} from {{a, 3}, {b, 5}, {c, 2}}?

My attempt: data = {{a, 3}, {b, 5}, {c, 2}}; output = Table[#[], #[]] & /@ data // Flatten {a, a, a, b, b, b, b, b, c, c}
47 views

### How can I add a different value to each item in a list?

I am trying to decrypt a modified Vigenère cipher text. I am unfamiliar with Mathematica, so I need some guidance. Here is what I want: ...
743 views

### Percent Difference between elements from 2 matrices

If i have a 22 by 25 table of values which depend on n and r, and a list of values that depends on r that is a 22 by 1 matrix, how can I find the percent difference between each element, by row in the ...
45 views

### Scan and Set over multi-dimensional data

Suppose I have the following: Table[x[i,j] = f[i,j], {i,1,10},{j,1,10}]; I want to set variables x[i,j] to have value ...
366 views

### Why can't I create {a,a,a,b,b,b,b,b,c,c} from x={a,b,c}; f={3,5,2}; Thread@Table[x,f]?

ClearAll[x, f] x = {a, b, c}; f = {3, 5, 2}; Thread[Table[x, f]] produces Table::nliter: Non-list iterator f at position 2 does not evaluate to a real numeric ...
I'm wondering if inserting an integer into a sorted list (in a way that the list remains sorted) can be performed in Mathematica in some fancy way in $\log(N)$ time?.. The question was asked here, ...