Questions tagged [list-manipulation]
Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.
9,651
questions
0
votes
0
answers
47
views
Automate generation of new list
Suppose there is a list of lists as follows:
BigList={{1,2,3},{4,5,4},{7,7,9},{10,11}}
and it is required to apply a given command separately on each sublist ...
0
votes
0
answers
66
views
Fastest way of removing outliers from a data set which depends on a variable
Suppose we have the following code:
...
3
votes
1
answer
115
views
Numerical precision of keys in Merge function
I'm trying to merge list member with the same numerical key values:
a = {53.8 -> x, Floor[53.81`, 0.2] -> y};
Merge[a, Total]
then I get:
...
3
votes
1
answer
109
views
How to delete members of a list by rule [duplicate]
I have a list:
lis = {"a",1,""}
and would like to delete from the list all elements that consist of "" to give:
...
-2
votes
3
answers
79
views
1
vote
1
answer
56
views
Applying a condition to a column in a table using If
Let's assume we have the code below (The below code is derived from answer @DanielHuber link and answer @Domen link)
...
3
votes
6
answers
280
views
`Drop` for list of elements of different dimensions
MWE is the following list
{{{1,2,3},4},{{a,b,c},d}}
I want to Drop the 3 and c here. (In reality, it is a very long list of ...
4
votes
4
answers
457
views
How to raise a vector to powers contained in a vector, change the list into a product, and do this for all the lines of a matrix, efficiently?
I want to raise the first vector var to the powers in a second vector, and then multiply the list, when the second vector runs over all lines of a matrix ...
2
votes
5
answers
279
views
How to find intersecting linear equations between two lists?
I have two lists of linear equations:
list1 = {x - y == 0, x + 2y == 0, 3x - y == 0}
list2 = {-x + y == 0, -x - 2y == 0, 3x - y == 0, 3x - 2y == 0}
I want to ...
0
votes
0
answers
44
views
How to solve numerically a fourth order BVP having a Boundary condition at Limit Approaches to 0
I have the following fourth order BVP (pde):
$\frac{1}{4}f_{yyt}+H^{4}(ff_{yyy}-f_{y}f_{yy})=\frac{1}{H^{2}R}(yf_{yyy}+2f_{yy})$
with boundary conditions:
$f(0,t)=0$, $f(1,t)=0$, $f_{y}(1,t)=-\frac{\...
-1
votes
1
answer
67
views
Match list to a pattern [duplicate]
I want to match a list to a pattern, but MatchQ is not doing the job as needed. For example, I need:
...
4
votes
3
answers
340
views
Fourth order BVP partial differential equation
I am trying to solve fourth order partial differential equation describing a fluid problem, by using Mathematica. The PDE is provided here as:
$(1/4)f_{yyt} + H^4(ff_{yyy} - f_y f_{yy})=1/{H^2R(yf_{...
1
vote
1
answer
85
views
How to generate all possible combinations subject to symmetry conditions
I have a list of 6 (possibly repeated) integers:
ints = {a,b,c,d,e,f};
and also a set of symmetry conditions:
You can switch the signs of elements 1 and 4 at the ...
3
votes
3
answers
201
views
Function to find the most common numeric ordered pairings (value, count)
Let us say that I have a list of numeric ordered pairs where the first number represents a value to be counted and the second number represents the count of that value. The following is one way to ...
0
votes
1
answer
38
views
Add a new column based on the complement of column data in a table
I have this code to replace the data of each row in a specific function and display a new column showing the values of the function
...
1
vote
1
answer
59
views
Finding the position of a list element using functions like Max on lists that might contain 'Indeterminate' values
I am working with lists of the following form:
...
2
votes
2
answers
75
views
Best way to extend the size and add terms to a SparseArray without expanding
Let's say I have a "small" SparseArray of any size, in the example $2\times2$
...
0
votes
0
answers
49
views
Operations on Sub Lists
Let us assume that I have the following list of lists:
foo = {{2, 1}, {3, 1}, {4, 1}, {2, 2}, {3, 1}, {2, 1}};
and that I want to multiply the elements of each sub ...
2
votes
2
answers
164
views
Union of lists with original order
I would like to combine a few lists such that the resulting list follows the order of the original lists, which will have disjoint elements, but their order is compatible.
...
1
vote
1
answer
80
views
How to check equivalence when variables in equations are replaced by their negatives?
In a previous post about checking whether two systems of equations are equivalent, the suggestion was to use the Reduced Row Echelon Form, which was great.
However, I now want to consider an ...
1
vote
2
answers
81
views
Reshaping a list as another nested list
I have the following list ( p to be some even number )
...
3
votes
1
answer
86
views
Find positions of unique elements in a nested list
I have a nested list with depth 6. The items in the list are mathematical expressions. I want to find the positions of the unique items in the nested list. I have found the following, which works for ...
4
votes
3
answers
209
views
How to make a list plot from a "vector array"?
I have an (excel) table where my first column have decimals from -3 to 3, and the other columns have associated values, in such a way that i have a "vector array" similar to this:
...
0
votes
1
answer
31
views
Solving list manipulation exercise involving longest sequence of identical digits in a list using functional programming idiom
I have been trying to improve my list manipulation skills by doing some of the exercises in Wolfram's Intro book. I am struggling to solve this question using only functional programming constructs. ...
1
vote
3
answers
158
views
1
vote
1
answer
47
views
Applying the binomial distribution to matrix data
The probability that a random variable $X$ with binomial distribution $B(n,p)$ is equal to the value $k$, where $k = 0, 1,\dots,n$. If we have the $(n\times m)$matrix and $N_j$,
$$f(x)= 1/2 \binom{3}{...
4
votes
4
answers
279
views
How to combine some ordered pairs
I have a list of ordered pairs:
{{1, 1}, {1, 2}, {2, 4}, {1, 2}, {1, 2}, {2, 4}, {2, 4}, {2, 4}, {4, 4}}
If two pairs {x_1, y_1}...
1
vote
0
answers
48
views
Formatting control points for BSplineFunction
I am trying to create an approximation to a level surface $F(u,v,w) = 0$ using BSplineFunction and control points sampled from the ContourPlot. I want to use these points to make a 2-variable ...
3
votes
2
answers
96
views
Flatten bottom $n$ levels [closed]
The documentation for Flatten states:
Flatten[list,n] – flatten out the top $n$ levels in list
Does a function exist to ...
-1
votes
2
answers
109
views
Combinations of two table
I would like to find all the possible combinations between TSet1 and TSet2 to create a table of 18 rows.
...
1
vote
0
answers
73
views
How can I make a list containing 5 rows and 10 columns from a list? [closed]
I have a list
list = RandomInteger[{10, 100}, 100]
I want to make a list containing 5 rows and 10 columns. I tried
...
3
votes
3
answers
240
views
Inserting a 0 in Specific Symbols
I have a very large network with 1000's of edges. Below is a small sample. The N is my label for Node and the number that follows is a unique identifier. I want to make all the edges on either side of ...
1
vote
1
answer
56
views
How can I compute the cross product of some sets of ordered pairs?
I have a list of sets of ordered pairs:
{{{1, 1}, {1, 2}, {2, 4}, {4, 8}}, {{1, 1}, {1, 2}}, {{1, 1}, {1, 2}}}
There are 4 ordered pairs in the first set, 2 ...
-2
votes
1
answer
79
views
How can you transform the format of letters in a list?
Q1:How to convert list1 into list2
list1={A, B, C, D, E, F}
...
2
votes
2
answers
97
views
Condition on the data of table
If you have a table and want to separate some data into columns according to certain conditions:
Let's assume we have the following table:
...
5
votes
3
answers
427
views
How can I count frequency of a list faster?
I have a list
list = RandomInteger[{120, 180}, {20}]
I want to count from the list elements $a$ satisfying conditions: $120\leqslant a <130$, $130\leqslant a &...
3
votes
2
answers
66
views
Using PutAppend to create data file for 2D plot
I need to append 2 real numbers x,y (a point coordinates) to the bottom of a file, so that these numbers form 2 columns, the x column and the y column. I need to plot the points later. Doing this:
<...
0
votes
1
answer
64
views
How to convert a $2 \times 2$ matrix with entries of $4 \times 4$ matrices into a regular $8 \times 8 $ matrix
I have tried to create the following matrix $$\begin{bmatrix} 0_{4} & \mathbb{I}_{4} \\ \mathbb{I}_{4} & 0_{4} \end{bmatrix}.$$
I have used the following code
...
3
votes
4
answers
145
views
List editing problem
I have an ill-formed list:
...
2
votes
1
answer
119
views
Central element of matrix
Let we have $(2\cdot r+1) \times (2\cdot r+1)$ matrix mat.
Is there a better way to extract it's central element,
rather than ...
6
votes
3
answers
190
views
Generate a table of elements whose number is equal to prime numbers
I have a list of words (strings) same as
...
1
vote
2
answers
71
views
Randomly replace some letters in words with hyphen
I have a list containing some related words
...
1
vote
1
answer
82
views
Find the feasible solutions of a minimal path set of vectors
Finding the feasible solutions for vectors representing minimum paths based on the mathematical basis:
First example
I need to create the constraints according to equations (1) and (2) above:
...
1
vote
1
answer
65
views
Max and Transpose in the Probability of a Union
If I have the code that gives the probability of the sum in general
...
1
vote
2
answers
131
views
Probability of a union with probability function of vector
I want to calculate the probability of a discrete random variable.
...
0
votes
1
answer
55
views
Apply an equation based on two sets with different indexes
Apply an equation based on two sets with different indexes
Simple example
If I have the following elements in the form of two sets with different indexes:
$m=\{m_1,m_2,m_3,m_4,m_5\}=\{1,2,2,2,1\}$
$p=\...
7
votes
2
answers
286
views
How can I sort all levels except the innermost level?
How can I sort all levels except the innermost level? The number of levels is unknown. For example:
list = {{{d, c}, {b, a}}, {{4, 3}, {2, 1}}}
If we needed to ...
0
votes
2
answers
78
views
Other methods extract the x-coordinates and y-coordinates from a list of multiple coordinate values and list them separately in two individual lists? [closed]
x={0.04,0.06,0.04,0.08,0.08,0.05,0.05,0.07,0.07,0.06}
y={0.25,0.4,0.22,0.54,0.51,0.34,0.36,0.46,0.42,0.4}
The two lists above represent sets of x-coordinates and y-...
2
votes
3
answers
304
views
Filling the areas enclosed by two curves and calculate them
I know that there are plenty of posts on this, but I just cannot find the right one that solves my issue. The issue is that I have two datasets that I plot them using ...
5
votes
3
answers
438
views
How to optimize performance with DeleteDuplicates?
Does anyone know how to improve this for speed performance? The code works fine, but DeleteDuplicates makes it really slow for large lists.
...