Questions tagged [list-manipulation]
Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.
9,392
questions
3
votes
3
answers
584
views
How to remove a high accuracy numerical number from a list?
My numerical calculation gives a list of numbers
list = {-0.36, 0.2499999999999992, -0.21, 0.36, 0.36},
I want to delete 0.25 ...
0
votes
0
answers
30
views
Calculation hangs when called an own function from own loaded package. Debug output shows strange things
I created a package a long time ago and it was working, but in the versions 13.2 13.3 an old created function hangs when called. If I evaluate the same function from a cell manually and then call, it ...
0
votes
0
answers
38
views
Matrix Dimension Changes
I am trying to run the following code:
...
0
votes
1
answer
41
views
Neglecting coefficients of a given list
Suppose I have some complicated expressions, I want to extract some terms with $\{a_1, \cdots, a_n\}$ out of the complicated expressions without considering coefficients.
For example, here is my trial....
3
votes
2
answers
113
views
How do I create a list of matrices based on lists I have?
Okay, so let's say I have these lists and a number
a = {1, 2, 3};
b = {4, 5, 6};
And now I want to create 3 matrices that each look like this
...
12
votes
6
answers
2k
views
7
votes
6
answers
551
views
Rearrange triple sublists
Given a set of triple lists (all contain element 9!)
tripel = {{5, 10, 9}, {4, 9, 3}, {3, 9, 8}, {4, 5, 9}, {9, 10, 8}}
I would ...
0
votes
0
answers
53
views
MinimalBy with argument and value
I need to find element of some list arr which is minimal by some function f.
But I need to get result in form ...
9
votes
8
answers
860
views
Shuffling two lists into each other
Given a subset s of Range[n] and two lists a and b, with ...
1
vote
1
answer
74
views
Value of a function over permutations of two lists
I want to do the sum (in Ising lattice gauge theory)
...
2
votes
3
answers
240
views
Getting all solutions to an equation on condition the variables are either 0 or 1
Given a list of 3-bit binary lists
b={{0,0,0},{0,0,1},{0,1,0},{0,1,1},{1,0,0},{1,0,1},{1,1,0},{1,1,1}};
I would like to have all possible solutions to
...
1
vote
1
answer
73
views
Map list of strings to appropriately nested functions
I have a list of strings consisting of sequences of "+" or "-"'s. For example, let's take the list
...
0
votes
0
answers
42
views
Selecting from a list of associations
From a list of Associations
...
2
votes
3
answers
186
views
Table with additional conditions for the generated objects
Suppose that I have a function
prob[n_] := Table[Subscript[p, i], {i, 1, n}]
that generates tuples with n entries that correspond to probabilities. What I would ...
0
votes
1
answer
68
views
A simpler way of identifying which elements of Tuples[{0,1,2,3},6] multiply with each of my codewords to give zero?
So I have a list of codewords. The codewords have length 64, so there are 64 codewords in my code. My code is over an alphabet of 4 (the code can be thought of as having four elements $0,1,2,3$ and ...
7
votes
4
answers
505
views
Fill an empty matrix with the depth of its elements
Given an arbitrarily nested empty matrix like for example
mat =
{
{},
{{}, {}},
{{}, {{}}, {}},
{{}, {{}}, {}, {{{}}}}
};
and knowing that
...
1
vote
1
answer
73
views
How can I make a map to solve in a list of coefficients of an equation?
I have a list
list = {{2, -4, 3, 1, -2}, {2, -3, -4, -1, -2}, {2, -3, 4, -1, -4}}
and
...
3
votes
6
answers
602
views
Repeating a list k times [duplicate]
I have a list, say $\{1,2,3,4\}$ and I would like to repeat this list k times to obtain a list of $4k$ elements that looks like $\{1,2,3,4,1,2,..,1,2,3,4\}$.
I was hoping something like ...
5
votes
5
answers
636
views
How to sort filenames in actual numerical order?
I have inherited a collection of files that are numbered... something like:
file-0, file-1, file-2, ... file-9, file-10, file-11, ... file-19, file-20, ...
When I Import them, they come in scrambled ...
7
votes
4
answers
275
views
Create a list of indexed variables and assign values in one line of code
It is easy to create a list of indexed variables
F/@{1,3,6,8}
I would like to assign values in the same line of code
...
4
votes
4
answers
207
views
Selecting elements from nested list based on condition
Assume that I have a nested list of the form
d = 0.1;
v = Table[{x, y, z}, {x, -1, 1, d}, {y, -1, 1, d}, {z, -1, 1, d}];
How do I select all elements {x,y,z} of ...
0
votes
2
answers
175
views
Sorting a list of functions by exploiting the recursive structure
Given a list of functions list and a vector of arguments {t, a}:
...
0
votes
2
answers
112
views
How to skip code in loop?
There is some box [a,b] and each box[a,b] have elements like
...
2
votes
1
answer
59
views
3
votes
4
answers
88
views
Is there a better way to calculate the number of codewords of weight $i$ in a list of codewords?
Background Info
I am interested in a better way of doing the following:
I want to find the weights of the following codewords (the weight of a codeword here can be defined as the number of nonzero ...
0
votes
1
answer
76
views
Trying to plot the Fourier transform solution to the heat equation on Mathematica [closed]
I have gotten the solution of the heat equation as
where f(y) is the initial heat distribution which I have been given as f(x) = e^([Sigma]x^2).
I am supposed to plot this at the value of sigma 1, 2 ...
2
votes
3
answers
177
views
How to express a list of lists of rules as functions?
Given a list of lists of rules as follows:
...
2
votes
1
answer
57
views
2
votes
2
answers
117
views
Multiplying elements of two lists in all possible orders
I have two lists:
U1 = {u10, u11, u12};
U2 = {u20,u21, u22};
and I want to get a third list that will be the product of these two lists in a particular order. the ...
2
votes
1
answer
59
views
How to modify a position on a list? [duplicate]
I have a set of points:
data := {{10, 15}, {20, 45}, {30, 97}, {40, 162}, {50, 221}, {60, 249}, {70, 231}, {80, 166}, {90, 75}, {100, -5}}
What I want to do is ...
0
votes
1
answer
97
views
How not to process the first list?
(I reconsidered my previous question as it didn't describe well what I wanted to implement.So I repost this)
There is a box [a,b] in order[x] generated in a random sequence.
...
3
votes
2
answers
250
views
How to map an unbalanced list of lists as functions?
Given:
Map[f, {{a, f, h, m, n, k},{a, b}, {z, d, f, h, k}, {c, d, e}, {c, p}}]
I like to have a list of ordered functions as ...
2
votes
4
answers
93
views
The first list is not processed
A randomly generated box[a,b] is in order[x] such that
...
1
vote
1
answer
39
views
How can I use Flatten[list, 1] in this list?
My code
list = Table[Expand[(k x - i)^2 - j^2 y^2], {k, 2}, {i, 2}, {j, 2}];
Flatten[list, 1]
I get
{{1 - 2 x + x^2 - y^2, 1 - 2 x + x^2 - 4 y^2}, {4 - 4 x + x^...
2
votes
2
answers
100
views
How to "complete" the table by making all of its rows to have the same number of elements?
Consider the following table:
...
1
vote
2
answers
72
views
How to delete a list from a list?
I don't know how to delete a list from a list.
For example, There is a list.
...
2
votes
7
answers
315
views
How can I get a list of symmetric polynomials?
Q1: Suppose I have an expression like this one:
$(1+x+y+z)^3$
How can I transform it into the following expression:
$$\{1,x+y+z,x^2+y^2+z^2,xy+xz+yz,x^3+y^3+z^3,x^2y+x^2z+xy^2+y^2z+xz^2+yz^2,xyz\}$$
...
1
vote
3
answers
91
views
Interpolating data which arent in the proper list form
I have some data which are structured poorly, and I want to interpolate them. This is the way they are structured:
...
7
votes
6
answers
483
views
Apply function to all first arguments of a nested list of rules
Currently, I have a nested list of rules of the form
lst1={1->a,2->{3->c,4->d,5->{6->f,7->{8->h,...}}}}
(where I don't know the length of ...
1
vote
0
answers
98
views
Optimize grouping of list of lists by elements
I have a sorted list of lists of size ~200,000 x 3. The data are such that the first element of each triplet loops through i = 1, 1.1, 1.2, ..., 199.9, 200, and for every value of i, the second ...
2
votes
2
answers
115
views
Convert list of variables to list of parametrized functions
I have a list of differential equations of some variables
eqns = {f[x,y,x',y'],g[x,y,x',y']}
e.g., f[x,y,x',y'] = x x' + y y'. ...
0
votes
0
answers
26
views
How can I find the coefficient of some function of varying inputs in a list? [duplicate]
I have a list
klist={4 K[{1}, {1}], K[{2}, {2}], (2 K[{2}, {1, 1}])/("Ndim")}
where K[{list_1}, {list_2}] is some ...
2
votes
3
answers
179
views
Evaluating a 2D function from a list and add the result to the list
Suppose I have a list like this
data = {{1, 2, 3}, {4, 5, 6}}
and a function
f[x_, y_] := x^2 + y^2;
I would like to evaluate ...
1
vote
2
answers
70
views
Listable (on certain level) custom function
I wish to make custom listable function (for 2D points) with the next behaviour:
...
0
votes
0
answers
59
views
Plotting list of points to a special graph
Given Mathematica code of eigenvalues in different variable-paths , I want to add experimental data in the path Gamma-X ; X-Gamma ; and M-Gamma .
Here is the code :
...
3
votes
4
answers
164
views
Calculate the Mean of lists of the same length
I have the function
...
6
votes
2
answers
389
views
Why Does Part Work Much Slower on Modified List?
Consider the following list:
tabb = RandomReal[{0.0000001, 10^5}, {10^6, 80}];
I want to extract, e.g., the columns from 1 to 20. It is reasonably fast:
...
6
votes
4
answers
412
views
Subdivide a sequence
Yesterday I couldn't solve a problem which seemed to be rather simple. I tried RepleaceRepeated, SequenceReplace and similar ...
1
vote
4
answers
136
views
How to prune from a list every element which doesn't share e.g. both its 1st and 2nd elements with SOME element in a specified other list?
This is a followup question to this one.
Let a and b be lists of lists like this:
...
6
votes
4
answers
650
views
Find a certain path through a matrix
I would like to get a functional solution and nice display form for the following problem:
1. Example data
...