Questions tagged [list-manipulation]

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

Filter by
Sorted by
Tagged with
6
votes
2answers
125 views

Generation of restricted increasing integer sequences [duplicate]

I am looking for an effective way to generate a complete list of integer sequences {a_1,a_2,...,a_n} of the length $n$ such that $$0\le a_1\le a_2\le\dots\le a_n&...
3
votes
1answer
71 views

Memory leak when creating a SparseArray

Problem: I have a list e={u,v,w} and wish to construct a sparse matrix with entries {u[i],v[i]}->w[i]. Note that the same ...
0
votes
2answers
76 views

Update: Removing the Outermost pair of bracket from a List

Let m1={{1,0},{0,1}}; m2={{2,0},{0,1}}; I want to evaluate KroneckerProduct[m1, m1, m2], and I want to do this as ...
4
votes
2answers
179 views

Maximum of all distances between any pairs of vertices of a random triangle

Given a set $S_n$ of $n$ points selected uniformly at random in a $d$-ball, I want to estimate the average length of the longest side of a triangle having as vertices any three distinct points of $S_n$...
1
vote
2answers
43 views

Find all minima of a list of points

Given a list of points {x[i],y[i]} I would like to find all the local minima of y Example: ...
2
votes
4answers
88 views

How to reverse the order in which ListPlot plots multiple array of numbers?

I am new to mathematica. I have been trying to plot a list of values. The list looks somewhat like this: list = {{1, 2}, {1, 2, 3}, {1, 2, 3, 4}} What I want is to ...
2
votes
2answers
58 views

Using a list inside NDSolve

I have a coupled differential eqations: ...
2
votes
1answer
35 views

alternate coordinate repetition from the list

The output of this code repeats every x coordinate except last node. But I want to print the coordinate in such a way that coordinate at every odd position should be repeated except last node. ...
5
votes
6answers
127 views

Highlight elements in the list using pattern matching

Starting from the following list: list = {{a, b, c}, {d, e, f}, {g, h, i}, {b, c, d}, {c, a, m}, {c, d, n}}; I want to ...
1
vote
2answers
74 views

Repeat every $ x $ coordinate except the last one

Below is the code to print the x value. ...
0
votes
1answer
60 views

Dynamically change the size of table

I have a loop structure which performs certain calculations and writes the results in some matrix $M$. When certain condition is satisfied the loop stops. Let's assume that this happens after $T$ ...
1
vote
2answers
32 views

Graph of the linear fit with the experimental points of different colors and numbered

I would like to graph the following points and their respective line of fit on the same graph, but I would like to know if it is possible that the points are colored with different colors just as in ...
2
votes
1answer
98 views

Grouping the list

Let's assume that I have randomly generated list llist = {{0, 1}, {2, 1}, {4, 4}, {0, 3}, {3, 4}, {2, 2}, {2, 3}, {2, 0}}; We can represent this data using the ...
0
votes
0answers
30 views

Finding/Printing Variables that Correspond to the Maximum Output of a List

I am very new to Mathematica and been having a problem that is frustrating because I feel that there must be a simple solution which I just can't grasp. Essentially, I am looking to automatically ...
0
votes
3answers
81 views
0
votes
0answers
62 views

Goldbach's Conjecture?

If we have a list of even integers, how can we find partitions of size 2, then determine if the partitions are composed of prime numbers? So far, I think I would have to use ...
0
votes
0answers
39 views

Matrix, basis, vector syntax

I am in the beginning of learning tensors, basis and other linear algebra subjects and am having quite some difficulty using mathematica in regards creating such objects that mathematically work. Or ...
2
votes
1answer
38 views

Another nesting question

I have a function F[i_Integer,B_List,l_list] which spits out a list {B',l'} where B' and <...
0
votes
0answers
30 views

Direct production between two arrays must have an array shape

I wish to have a result such as: {0,1,0,0} after producing two vectors: v1={1,0} and v2={0,1}...
5
votes
6answers
543 views

Representation a matrix as a colored square shape

I am sure that I have accidentaly seen before a way to construct a square shape corresponding to a matrix. For example if we have a 5*5 matrix: ...
1
vote
1answer
32 views

Error message when referring to the value of a part of one element in a list [closed]

The following works fine to define an element of a two-argument list: T[1, 2] = {3, 4, "yes"} But when I try to change the third part, like this ...
3
votes
3answers
134 views

Level is deleting an item form my list

I have a list list={{{{2, 4}, {1}}, {3}}, {{{2, 4}, {3}}, {1}}, {{{1,2}, {3}}, {4}}, {{{1, 2}, {4}}, {3}}, {{{3, 1}, {2}}, {4}}, {{{3,1}, {4}}, {2}}} I want to ...
0
votes
3answers
70 views

Composition of Maps

I want to create a composition of several lists. For example: ...
1
vote
1answer
62 views

Compute the length of each string in a set [closed]

Say I have done some computation, and it gives me the following set of string: ...
1
vote
0answers
40 views

How to confirm the list of plot unique

I have a list of plot in a list called modes. I am interested in knowing whether this list is unique or not, meaning all the plots are different from one another. ...
2
votes
2answers
79 views

Use Mathematica to split a sequence according to other two sequences

I want to use Mathematica to solve the following problem: For example I have a sequence 101. I want to compare it with $1101$ and $0101$. The comparison has the following procedure: Check the first ...
0
votes
3answers
51 views

For loop and Append to update a list

I want to update a List, using a For-statement. It doesn't work as I expect. my data is like: ...
1
vote
1answer
95 views

Randomsample without repetition [closed]

I'm looking for a simple way to generate random samples of lists of integers such that each time I sample I'm sure it chooses a new random sample. This is closely related to Picking random items out ...
4
votes
2answers
108 views

Improper formatting for input to ListPlot3D, backwards incompatibility on 12.1?

For context, I am a brand new user to Mathematica using version 12.1 on Linux. I'm looking at an old notebook (2011) that looks at the inviscid burger's equation. The relevant bits from the notebook ...
1
vote
2answers
27 views

Follow-up to “Plot, extract data to file”

This is literally a follow-up to part of Mr.Wizard's answer to: Plot, extract data to a file Specifically in reference to ...
1
vote
1answer
62 views

How to compute k'th tensor power of matrix

Is there a 1-liner to compute $M^{\otimes k}$ where $M$ is some matrix and $\otimes$ is the Kronecker product? The documentation says I can write ...
3
votes
3answers
211 views

Group a list based on multiples of sublists

I have a list of lists like this one, where the sublists vary in length. ...
0
votes
0answers
55 views

Nested operations in Lists as a function of the times it is applied

I have a fixed list labels = Table[i,{i,k}] for some fixed $k$. There is a way of picking some sulists of this list with some property that I am interested in. I ...
0
votes
1answer
39 views

How to apply color gradient in listplot based on the density of points

I have a list of points ( a list with sub lists which are {x,y} coordinates. I would like to have a listplot where the areas with higher density of points are in darker colors and areas with lower ...
1
vote
0answers
39 views

Using the Line command with a bound on distance between points

Suppose I use the Line command applied to a list (or more accurately apply Graphics[Line[list]] or ...
7
votes
3answers
289 views

ReplaceAll, Unexpected output

Each week I import a dataset, and every week the dataset differs in length (the number of records). After the import I need to do some transformations. One of these transformations is the ReplaceAll. ...
5
votes
2answers
318 views

Summing over Partitions

Imagine I have a list of integers $l=\{l_1,l_2,...,l_{50}\}$, say, for example l = RandomInteger[10, 50] and I want to find how many ways there are of summing ...
9
votes
2answers
221 views

How to cut a list by max sum

{5, 10, 3, 8, 9, 8, 8, 4, 1, 7} let maxsum=20, then I get ...
1
vote
2answers
47 views

Is there a workaround to dereference a list element that's the name of an undefined symbol, and iteratively assign values to the symbols in the list?

The title mostly covers what I would like to do. The image below shows in some situations it is possible dereference an element in a list using Evaluate to assign a value: ...
1
vote
1answer
35 views

How to check if a complex number belongs to a quadratic field

I am working with lists of complex numbers and want to be able to determine which out of these lists contains only elements from a certain quadratic field, $\mathbb{Q}(\sqrt D) = \{ a+b\sqrt D :a,b \...
2
votes
1answer
102 views

How do we take certain elements from a list?

Say we have a list ...
0
votes
3answers
77 views

ReplaceAll in list not working as expected [closed]

This is my code. lst = {1, 3, 5}; ReplaceAll[lst, lst[[2]] -> {7, 9, 11}]; lst It is supposed to get output ...
1
vote
4answers
147 views

How would we extract elements of a list greater than a certain value? [closed]

Say we have a list {35,210,67,950,32,365} how would we extract all the elements greater than 100 from this list (using a function)? The desired output would be ...
7
votes
2answers
183 views

Find All Permutations for Multiset

Take a list with repetitions, say {a, a, b, c}, and some permutation thereof, say {c, a, b, a}. I want to know which ...
0
votes
2answers
112 views

How to do two different kinds of binning for a given list of elements?

I have a long list consists of float numbers with some of them duplicated as shown below. I want to divide this list into bins; with equal bin width so that in each bin there might be one or more ...
1
vote
1answer
63 views

How to sort the list A in an increasing order, such that I can modify the other list B with change in element position of list A

I have two lists A and B, I am trying to change modify the elements of list A in an increasing order such that my list B should also be changed according to list A. The node no list is given below. <...
0
votes
3answers
54 views

Manipulating a list while maintaining the nested list structure

Suppose I have a list of pairs of complex numbers with nesting as follows ...
0
votes
0answers
44 views

Solving equations using lists of data

I have a list of pairs of numbers that represent empirical data for U(n) e.g. {{n1,U1}, {n2,U2},...}. Is there a way to use this discrete data set to solve something along the lines of: ...
1
vote
1answer
99 views

How can I find different areas of triangles from a list of points?

If I have a list of points such as {{1, 1}, {4, 7}, {24, 67}, ..., {17, 83}}, how can I find the area of triangles formed by different combinations of these points? ...
1
vote
2answers
175 views

Converting a list to an array

Let's assume that I have a list that I can access like list[[i, j]] How can I convert it to an array such that: ...