Skip to main content

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
7 votes
5 answers
255 views

How to keep specific rows of a matrix based on their second element

Suppose I have the following list: list1 = {{a, 1, c, v, f}, {m, 2, s, f, a}, {s, 2, d, f, g}, {k, 3, g, f, a}, {l, 2, h, j, k}, {b, 1, n, m, d}} I need to ...
Delaram Nematollahi's user avatar
1 vote
2 answers
47 views

How can I select the positive roots in a list calculated with NSolve?

I've used NSolve to determine the roots of a nonlinear function. There are both positive and negative roots, and I only need the positive ones. I've tried using: <...
agaminon's user avatar
  • 113
0 votes
0 answers
65 views

How can a program be configured for these steps?

Is it possible to create a program that implements sequential mathematical steps... in order to be circulated to more than one selected set? Step 1: For the following sets: $$S_1=\{x_1,x_2,x_3\},S_2=\{...
Emad kareem's user avatar
5 votes
6 answers
325 views

Selecting a list of strings associated with a long list of strings

I have two lists of strings: ...
Tugrul Temel's user avatar
  • 6,233
3 votes
1 answer
172 views

What is wrong with this code to convert all elements of a list to a LaTeX file?

I have a list that I need to convert to LaTeX: ...
minhthien_2016's user avatar
1 vote
0 answers
62 views

What is another way to write this equations in this list?

I have mylist: mylist = {{6, 7, 6, 2}, {7, 9, 7, 3}}; Here are two ways that I write equations from mylist: ...
Thuy Nguyen's user avatar
  • 1,131
5 votes
2 answers
146 views

Nested associations - flatten and unflatten

Assume I have ass = <|"A" -> 1, "B" -> <|"B1" -> 2, "B2" -> 3|>|> I can flatten it to ...
Stefan Gillessen's user avatar
6 votes
6 answers
426 views

Avoiding (numbering) duplicate keys

...
eldo's user avatar
  • 82k
2 votes
3 answers
216 views

Selecting triangle coordinates with all-integer centroids

Following is a list containing coordinates of triangles in 3D space: ...
John Paul Peter's user avatar
4 votes
2 answers
141 views

Assign values from a list to a multivariable function that also has other arguments

I am new to Mathematica's way of programming. I have a multivariable function, part of whose values are available as a list, and the remaining in another list. To illustrate, I will present my problem ...
haricash's user avatar
6 votes
6 answers
503 views

How can I select element of a list containing (a,b) where both a and b ara rational numbers and not integers?

I have a list of equations and I solve them ...
Thuy Nguyen's user avatar
  • 1,131
2 votes
2 answers
235 views

How can I select real elements that not an integer and rational numbers?

I have a list list = {2, -1, 3/5, (Sqrt[2] + 1)/3, Pi} How can I select from the list real elements that not integer and rational? That's mean, how can I get ...
minhthien_2016's user avatar
1 vote
0 answers
65 views

Why is SequencePosition or SequenceCases so slow on large lists?

I observed that SequencePosition or Sequence Cases on a list of around 60'000 digits is so slow that I had to sort out to string pattern matching. Is this normal behavior or should Wolfram have a look ...
markilux's user avatar
  • 121
3 votes
2 answers
171 views

Find non-descending sequences of list pairs

...
eldo's user avatar
  • 82k
1 vote
0 answers
65 views

Export data vertically

I have data that I want to export to a text file. ...
Alyasaa Jasim's user avatar
5 votes
3 answers
224 views

Extraction of sublists containing certain sequence pairs

list = {{a, b, c, d, a}, {e, f, a, b, c, d}, {a, b, p, q, c, d, g, h}, {c, d, p, q, a, b}, {a, c, b, d}}; I want to filter sublists of ...
eldo's user avatar
  • 82k
1 vote
0 answers
106 views

Transpose Subdivided and Imported Data [closed]

I am trying to transpose two data sets for ListLinePlot. Set 1 is imported from an Excel file, and the second set is created by ...
User's user avatar
  • 11
3 votes
1 answer
85 views

Extracting sub data from large one [duplicate]

LargData = Table[{i, 2 i, 3 i}, {i, 10000000}]; // AbsoluteTiming {0.450277, Null} I want to extract specific columns from the data above but it takes ...
MMA13's user avatar
  • 4,679
3 votes
5 answers
286 views

How to select elements from a list of strings?

...
Tugrul Temel's user avatar
  • 6,233
5 votes
1 answer
120 views

More concise forms generate list with elements 0 and 1

I need to generate all such lists, it consists of 14 1's and 4 0's, there should be at least 3 1's between two adjacent 0's. I came up with a pattern matching approach, it's a bit long. ...
vector's user avatar
  • 243
1 vote
1 answer
72 views

How to obtain positions of graphs satisfying certain conditions?

I first generate some random graphs, and then the following code can filter graphs with maximum degree 8. ...
licheng's user avatar
  • 2,059
6 votes
5 answers
412 views

Anti-diagonal matrix with alternating signs

I am having trouble modifying the code below so that the sign of the x alternate. That is, from the upper right corner it should read ...
Morcus's user avatar
  • 309
6 votes
8 answers
961 views

Select twins from a list of triples

list = {{1, 1, 1}, {1, 2, 3}, {1, 1, 2}, {1, 2, 1}, {2, 1, 1}, {2, 3, 2}, {4, 5, 6}}; To select sublists containing two equal elements ("twins") I ...
eldo's user avatar
  • 82k
5 votes
2 answers
136 views

Obtaining Pairs of Consecutive Elements with Conditional Adjustment

I've encountered a particular problem and was wondering if anyone has any insights on how to approach it more efficiently or elegantly. To be accurate, given the list: ...
E. Chan-López's user avatar
0 votes
1 answer
81 views

How Can I Use an Element of a Tuple as an Argument for a Pure Function?

(If I should elaborate on the circumstances, tell me.) I want to do the following: Suppose I have a tuple tuple={x,4,something,...} and I want to define a pure ...
Confuse-ray30's user avatar
2 votes
3 answers
103 views

I'm tired trying to get subsets

t={{a,b},{},{},{},{a},{a,b},{},{a,b,c},{},{b}} s={{},{a,b,c},{a,b}} Thread[Subset[t,s]] I'm tired of trying to calculate: {a,b} [which is the intersection [{a,b}, {...
Alyasaa Jasim's user avatar
4 votes
1 answer
96 views

Tensor product inside the compiler

The compiler does not have support for tensor product, are there any packages that implements the tensor product in a way that can be compiled? I need to take the tensor product of several numeric ...
Felipe's user avatar
  • 609
0 votes
0 answers
45 views

Simple question on ReplaceAll funciton

This is working. Array[f, {3, 3}] /. f -> g {{g[1, 1], g[1, 2], g[1, 3]}, {g[2, 1], g[2, 2], g[2, 3]}, {g[3, 1], g[3, 2], g[3, 3]}} This is working. ...
Satoru Mochizuki's user avatar
0 votes
1 answer
84 views

Generating a list of unions from subsets

I have ...
Alyasaa Jasim's user avatar
3 votes
3 answers
290 views

How can I remove system of equations have no solution in this list?

I select pair of tangents and find point of intersection of them. ...
minhthien_2016's user avatar
7 votes
3 answers
243 views

Insert abs into two adjacent terms of the expression

Give an expression expr = a - b - c - d - e; I need to add abs between adjacent letters, the desired result is ...
vector's user avatar
  • 243
3 votes
2 answers
86 views

Multiple append over a Dataset

I have the following association : ...
Jocelyn Minini's user avatar
3 votes
5 answers
146 views

Sorting logic and generation of letter sequence

In the context of experimental designs, it is common to generate the various treatment names to build the factorial design table. The table of the 2^2 design reads : For the 2^3, the table reads : ...
Jocelyn Minini's user avatar
5 votes
4 answers
335 views

How can I write the equations of the tangent plane to the sphere at all points in a list?

I have a list list = {x, y, z} /. Solve[{(x - 1)^2 + (y - 2)^2 + (z + 3)^2 == 7^2}, {x, y, z}, Integers] {{-6, 2, -3}, {-5, -1, -5}, {-5, -1, -1}, {-5, 0, -...
Thuy Nguyen's user avatar
  • 1,131
8 votes
3 answers
144 views

What is another way to write the equation in the form $A x + B y + C z + D = 0$ where A > 0 and GCD[A,B,C,D]=1?

I am trying write the equation of the plane passing through a point $A(x0, y0, z0)$ and take vector $w(A,B,C)$ as a normal vector. The equation has the form $$A(x-x0) + B(y-y0) + C(z-z0)=0.$$ I would ...
minhthien_2016's user avatar
2 votes
1 answer
206 views

How to make a list of three distinct points are not collinear so that their coordinates consist of nine different numbers from 1 to 9?

I am trying to make a list of three distinct points are not collinear so that their coordinates consist of nine different numbers from 1 to 9, ...
John Paul Peter's user avatar
6 votes
6 answers
578 views

How can I select three distinct points are not collinear?

I have a list ...
John Paul Peter's user avatar
4 votes
3 answers
380 views

How can I select elements {a,b,c,d,e} in a list so that Or[GCD[a, b, c] == 1 , GCD[d, e] == 1]?

I have a list list = {{-4, -7, -3, 2, 5}, {2, 4, 2, 3, 9}, {2, 4, 6, 3, 5}}; I would like to select elements {a,b,c,d,e} from the list so that GCD[a,b,c]=1 or GCD[...
John Paul Peter's user avatar
5 votes
3 answers
198 views

How can I make the list of largest abscissae from a nested list of coordinates?

Suppose I have a nested list of coordinates as: ...
codebpr's user avatar
  • 2,443
7 votes
5 answers
378 views

How to flatten a mixed multilevel list?

I want to Flatten: ...
user57467's user avatar
  • 2,788
0 votes
0 answers
58 views

How to adjust Do loop with conditions?

This code works as expected. ...
Tugrul Temel's user avatar
  • 6,233
0 votes
1 answer
58 views

Mathematica can not recognize the wanted element in a matrix when doing a numeric integral, even though it is plotted on the last step? [closed]

As shown, function 'TestF' is defined via interpolation and maps a number to a 4 by 4 matrix. Its (3,3) element is plotted at step 141, but not recognized in the numeric integration within the same ...
dudulu's user avatar
  • 159
1 vote
0 answers
30 views

Insert function not working [closed]

...
1goncalo1's user avatar
7 votes
4 answers
184 views

Combining expressions and variables to list

I thought this one was easy, but no! How do I get from u = 7; k = 9; r = 4; to {{u, 7}, {k, 9}, {r, 4}} without using ...
user57467's user avatar
  • 2,788
2 votes
1 answer
123 views

Construct a list of permuted circles containing arrows [closed]

I am drawing a picture as containing several raws addressed by any permutation of three circles with different radii. My difficulties to solve which I need clues are: 1- Inserting an arrow inside any ...
monfneg's user avatar
  • 585
12 votes
5 answers
804 views

How can I remove empty lists { } from a nested list?

I have a list: list={{{1},{2},{1,2},{1,2,3},{},{}},{{2},{3},{}}} I would like to remove the empty lists {} to get: ...
Thuy Nguyen's user avatar
  • 1,131
4 votes
5 answers
232 views

Partitioning a list based on the count of a certain marker

My goal is to get lists containing k number of 0.1s. For example, in ...
Soon's user avatar
  • 648
2 votes
1 answer
103 views

How to find extra points of a graph in a list?

I have a list: list = {{-4, -7, -3}, {-2, -5, -1}, {1, -2, -3}, {2, -1, 3}, {5, 2, 1}, {7, 4, 3}}; I want to make all functions, e.g $f(x) = \dfrac{(x+4)(x+7)}{x-...
John Paul Peter's user avatar
0 votes
0 answers
103 views

Checking whether a set system is intersecting

I have a set of set systems g. I want to select from g those sets systems that are intersecting, that is for every two sets in ...
Sean Longbrake's user avatar
6 votes
1 answer
142 views

Want Map function to apply over sum of terms but not product

For a given function F, if I use Map[F,a+b+c d], Mathematica returns, as desired: F[a]+F[b]+F[c d] ; However, for ...
user160385's user avatar