Questions tagged [list-manipulation]
Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.
9,653
questions
0
votes
1
answer
81
views
How to apply the Manipulate function on a 5D data set and visualize the data using ListContourPlot? [closed]
Say you have a data set with 5 columns and each column is defined by the variables theta, phi, x, y, z such that data(theta, phi, x, y, z).
I would like to use the Manipulate function on this list and ...
3
votes
5
answers
184
views
Importing Specific Data from a Text File
I am quite new to Mathematica. I have a text file that upon importing has a repetitive structure with characters included. I need to extract only the following in numbers only (no letters, dash lines, ...
4
votes
4
answers
211
views
How to tally a list of lists only by considering the first element of the sub list
We need to Tally a list of lists only by considering the first element of the sub lists and then sort the resulting list.
As a simple example consider
...
4
votes
5
answers
141
views
How to implement this zip function? zip[g,{f[{a,b}],f[{c,d}]}] to f[{g[{a,c}],g[{b,d}]}]
I have a function that returns an expression in the form f[{a,b}], and I use this function twice and assemble the expression ...
5
votes
4
answers
241
views
Select elements from a list based on alphabetical order criteria
I have this code to generate the anagrams for a 6 letters word:
...
3
votes
1
answer
98
views
How to sum over Slot inside MapThread
I am trying to do simple operations with several lists. In this context, I was wondering if a sum over Slot is possible inside ...
3
votes
0
answers
49
views
How can I access subsets in manageable chunks?
I have a large subset (as an example).
subset = Subsets[Range[8000], {2}]
I cannot evaluate this as I don't have enough space.
So the question is how can I access ...
2
votes
1
answer
163
views
How can we arrange data for ListLinePlot? [duplicate]
I have this data
...
0
votes
1
answer
54
views
Build 2D lists of functions and variables in different combinations
Can someone give examples on how to build 2D Lists of function and expressions by the given vectors? I have the following:
V1={a,b,c}; V2={1,2,3}; V3={x1,x2,x3};
...
2
votes
4
answers
222
views
How to convert the form of a solution from solve {x -> 1, y -> 1, z -> Sqrt[2]} into a list form {1, 1, Sqrt[2]}? [closed]
How to convert the form of a solution from solve as follows:
{x -> 1, y -> 1, z -> Sqrt[2]}
into a list form
...
5
votes
2
answers
180
views
How to select right triangles and non right triangles given their coordinates
I have a list of triangle coordinates in 2D-space:
...
0
votes
0
answers
51
views
How to convert RowBoxes into list of math expressions?
I have following RowBox which represents Step By Step solution of undefined integral
...
4
votes
1
answer
76
views
Flattening nested data generated in a table
The data in the following is structured like this $\{\cdot,\{\cdot,\cdot\}\}$, but I need it like this $\{\cdot,\cdot,\cdot\}$. How do I do this?
...
0
votes
1
answer
47
views
Extracting coefficients from a list of expressions
I have a list of the form,
...
0
votes
0
answers
67
views
JacobianMatrix function flattens input in column order
The JacobianMatrix function appears to flatten its input in column order. Both of the following queries (Wolfram Alpha syntax) give the same result:
Q1: "JacobianMatrix of {{a_1+a_2, a_1+ a_2, ...
-1
votes
3
answers
98
views
How to generate an array with specific conditions?
To randomly generate an array of 10 non-negative integers with a mean of 3 and a variance of 2.
...
0
votes
1
answer
48
views
Syntax regarding Manipulate plot with multiple functions
I am facing the following issue; I have the solution of a ParametricNDSolveValue and would like to plot several solutions with varying parameter in the same Manipulate to see qualitative differences. ...
4
votes
2
answers
323
views
Get cumulative sums in a list without using a for loop [closed]
I want a list of the kind list = {a,a+b,a+b+c} for list plotting. The quantities of the list come from a function. Let us say this is
...
2
votes
1
answer
81
views
Find disjoint subsets and their union is {1...9}
I have such a list
sets = Select[IntegerDigits /@ (Range[Floor@Sqrt@987654321]^2),
DuplicateFreeQ@# && FreeQ[#, 0] &]
I want to pick all subsets of ...
0
votes
0
answers
39
views
Writing list as disjoint union of input lists
Suppose I have two lists,
s1={{1,2,3},{3,1,2},{3,1,2},{2,3,1},{3,2,1},{1,3,2}}
and
...
1
vote
0
answers
34
views
Efficient chain rule implementation
(there is a fair amount of context here) I am implementing a generalized chain rule to do some work, say for order 3 in derivatives ($\partial_i = \partial/\partial x_i$):
\begin{align}
\partial_i \...
5
votes
2
answers
519
views
Fill a matrix with randomly placed elements that are a certain distance apart
Problem statement
I want to populate a matrix of points with randomly placed elements, here denoted as x. In all matrix rows there must be an equal number of x-...
6
votes
5
answers
377
views
Combining duplicate elements in a list
I have a list of the form,
mylist = {{0.1, 1.2},{0.3, 2.1},{0.1, 0.5},{0.4, 0.4},{0.4, 0.1},{0.1, 1.6}}
I would like to create a function, ...
0
votes
2
answers
56
views
How to use FoldList for matrix multiplication?
I'm trying to use FoldList to create successive matrices that depend on a changing parameter n, so the transition matrices are ...
5
votes
1
answer
170
views
How could I speed up this tensor product?
I have to take tensor products of lists of tensors and I want to include the possibility of tensors whose components have high working precision. The tensors are all totally symmetric, so the first ...
2
votes
6
answers
284
views
How can I find all the different ways to group integer numbers from 1 to 10 into 3 lists?
(Unfortunately, I couldn't change the bounty message. By n above I meant the number of sublists.)
How can I group a list of integers from 1 to 10 into 3 sublists of ...
1
vote
1
answer
54
views
How to convert a list of polynomials with different degrees into a list of lists?
I asked a question about converting a polynomial into a list.
Now I have a list of polynomials. For example,
...
5
votes
4
answers
313
views
How to convert a polynomial into a list?
I have a list of polynomials. Each polynomial looks like:
p[1, 2, 5] p[3, 6, 9] p[4, 7, 8] - 3 p[1, 2, 4] p[3, 6, 9] p[5, 7, 8]
How to convert each of these ...
4
votes
2
answers
220
views
Reverse association and map through its values/keys
I suspect this could be done in a shorter and more readable code:
Challenge: do it without Normal and Association.
...
0
votes
2
answers
82
views
Generating lists where new elements depend on the previous element
I am interested in using some type of list or table in-built Mathematica function to generate a list, where the elements of the new list not only depends on the input values of a previously defined ...
6
votes
5
answers
333
views
How to create sublists of a list based on the relation between their elements?
I have a large data set looking like this:
...
6
votes
5
answers
484
views
How to remove extra brackets from a list?
I have a list which looks like the following:
list1={{{a,b,c},{a1,b1,c1},{an, bn,cn}},{{f,j,k},{f1,j1,k1},{fn, jn,kn}}}
And I need it to be as follows:
...
9
votes
5
answers
387
views
Reconstruct list from its PositionIndex
Is there a more elegant or shorter way of reconstructing a list from its PositionIndex?
The following I regard quite cumbersome:
...
3
votes
4
answers
174
views
Sort Column as a Row
I have
a = {1, 2, 3, 10};
b= {2, 3, 4, 8};
t= Do[If[a[[i]]+b[[i]]>3,Print[a[[i]]],"No"],{i,1,4}];
2
3
10
I need to get the result; t={2,3,10}
8
votes
5
answers
361
views
Element-wise vector-matrix exponentiation
I would like to exponentiate the vector x = {x1,x2} element-wise with the non-square matrix A = {{1,0},{1,1},{0,1}} so that the ...
11
votes
5
answers
522
views
Isomorphic lists
Is there a function that outputs True if lists are isomorphic (there exists a rule that changes the first list into the second one and inverse of the rule changes ...
3
votes
3
answers
173
views
Generating permutations where no item appears in its original position [duplicate]
Given a Range[n] list, I need an algorithm that takes a permutation and output the next permutation. These permutations have the property that every item is ...
0
votes
0
answers
32
views
Evaluating determinant with entries from ./ output
I generate 16 values (this is a differential equation shooting method problem) from this kind of evaluation,
y41 = Evaluate[y4[tf1] /. torsolve4];
When I use them in Det[], it does not work because ...
2
votes
1
answer
48
views
How to quickly join in the following way? [duplicate]
Consider the following table:
tab = RandomReal[{0, 1}, {10, 3}];
subsets=Subsets[tab, {2}];
How to quickly reduce subsets to a ...
6
votes
3
answers
254
views
How to quickly join in the following way?
Consider the following table:
tab = RandomReal[{0, 1}, {10, 3}];
subsets=Subsets[tab, {2}];
How to quickly reduce subsets to a ...
6
votes
3
answers
177
views
Use sequence-functions to find certain sublists
I want to split a list of positive Integers into sublists whose
ascending elements differ by 1.
list = {1, 0, 1, 0, 1, 4, 5, 6, 5, 8, 1, 2};
This can be done ...
2
votes
3
answers
107
views
Count consecutive repeated patterns in a list [closed]
Given a list such as:
...
5
votes
3
answers
127
views
Tally elements in a list of matrices up to an overall sign
I have a list of matrices like the following one with 6 elements:
...
1
vote
1
answer
109
views
Map array of functions
What is the most elegant way of mapping an array of functions to an array of arguments of the same length? In practice I want to map {f1,f2,f3} and ...
5
votes
3
answers
277
views
Searching for a list in a list
I want to see if a specific list is part of another list and get either True or False.
As an example:
...
2
votes
2
answers
52
views
Do one calculation over the whole list [closed]
I am trying to calculate the numerical residue of the function, but I want to perform it at the whole list and as a return. For example, let's take
...
0
votes
0
answers
18
views
How to remove part of a plot range between the data? [duplicate]
Is there a way to manipulate a plot range to be non continuous?
I mean, I have some data that goes from x=18;;25 and then x=45;;50.
I want to plot the in the same ListPlot, but if I do so there's a ...
1
vote
2
answers
57
views
Multiple assignments of items of a list [closed]
Suppose to have a list of items and two lists of indexes that are parametric and for example are:
l={2,3,5,7,11,13,17}
i1={3,4,7}
i2={4,7,3}
I need a clever code ...
7
votes
1
answer
125
views
DuplicateFreeQ VS UnsameQ
What is the exact difference between
DuplicateFreeQ @ arr and UnsameQ @@ arr ?
I checked on many examples and found no ...
1
vote
1
answer
89
views
How I can write the equation of the line as diameter of this circle?
I have this code.
ClearAll;
pI = {-1, -2};
pM = {x, y};
myr = 25;
list = {x, y} /.
Solve[{(x - pI[[1]])^2 + (y - pI[[2]])^2 == myr^2}, {x, y},
Integers]
I ...