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
2
votes
4answers
221 views

Use replacePart from an element n to an element m of a list

I would like to replace a part of a list from an element n to an element m by zeros. I believe the function ReplacePart could be useful Example: I want to replace elements from 2 to 4 by zeros : ...
1
vote
0answers
27 views

What subsequences does SequenceReplace consider

Consider SequenceReplace[{a, b, x, x, a, c}, {a, e_} :> e]. What subsequences does SequenceReplace consider? The ...
0
votes
1answer
61 views

Using :> vs -> in SequenceReplace

The first example on the page for SequenceReplace is the following: SequenceReplace[{a, b, x, x, a, c}, {a, e_} :> e] ...
7
votes
3answers
327 views

Flatten simple list

I know this is probably a very silly question but I am trying to get {x,y,z,p} to be x,y,z,p. For this I am using Flatten in this way: ...
2
votes
2answers
54 views

creation of sublists by rules

I have a list consisting mixed strings and numbers: ...
0
votes
3answers
333 views

Python recursive bisection algorithm to Mathematica

I've been sitting on this problem for a while and i am kind of stuck. I am pretty new to Mathematica and have been trying to implement a recusive Algorithm, which splits/bisects a list of items in ...
3
votes
3answers
325 views

How to find a median of odd and even numbers from a list of numbers

For a given list, say {94,35,47,29,86,40,46,72,87}, how can I find a list of even and odd numbers. Here is the output after trying with the suggested solution in the answer. After putting the number ...
3
votes
1answer
114 views

Sublist creation, splitting and joining

I have a not very usefully-formatted string list and I would like to create certain sublists from it. ...
0
votes
1answer
45 views

ComplexListPlot not ploting [closed]

In a nutshell i have to plot a sequence of complex numbers to roughly see if it converges or not. I've created the list using the following ...
0
votes
1answer
28 views

How to deploy cloud application that graphs two companies net profit

What I want to do is to deploy a cloud application that would compare two stocks and (for bonus if it is possible) to also compare the net profit of two companies on a graph. I tried: ...
5
votes
3answers
193 views

Extract specific string from a list of strings

My question is similiar to previous questions (see here or here), although the issue is maybe somewhat more complicated: I have a list with strings like this: ...
10
votes
1answer
233 views

Understanding Partition

I came across the difficulty of understanding the logic of interaction of the fourth and fifth arguments of Partition. Here is an example: ...
2
votes
1answer
126 views

Cannot assign variable value inside Do Loop

This is more of a conceptual problem. Suppose I have three lists. x1 = {1, 2, 9, 10}; x2 = {5, 6, 7}; x3 = {9, 10, 13}; Now, I wish to keep only the first two ...
1
vote
1answer
46 views

Is there an efficent way to rearange lists of lists where transposing the whole list is no option?

I have a list of lists of lists, listing pairs of pairings. {{{a,b},{c,d}},{{a,e},{f,g}},....} I want to apply a function to this list that gives me a 4 level list where each first level element ...
3
votes
3answers
197 views

Removing complex numbers from a set

I have the following list: ...
1
vote
2answers
87 views

How to link value pairs to formula

I got this formula ...
4
votes
3answers
105 views

Thread map to 2 lists of inputs, including the nondiagonal terms

Given a function f and two lists of variables {a1,a2,...}, {b1,b2,...} How can I generate a following list ...
2
votes
1answer
95 views

Using StringExpression in a string list

I'm trying to search in a list of strings those who match a pattern. But it seems that StringExpression in functions such as ...
7
votes
4answers
366 views

AnyTrue is too good (compared to MemberQ)

Let L be a list of integers, and ⓝ denote an explicit integer. I've thought the most natural way to tell whether ⓝ belongs to L is In[1] MemberQ[L, ⓝ] But there ...
3
votes
1answer
107 views

Is it possible to get a graph for Taiwan water area

I tried to get a graph for water area in Taiwan, but somehow it doesn't seem to work: ...
2
votes
3answers
83 views

creating sublists by rules

I have a list: lis = {{ghi ,0,1,0,1,3,prq ,2,4,3,2,5},{abc 12-3,0,0,2,0,1,def 1-3,0,1,1,1,3}} I'd like to: delete each element whose first sub-element does not ...
4
votes
5answers
321 views

Creating sublists by rule

I would like to make a sublist consisting of the four elements that follow each occurrence of 1, 2 in the list: ...
5
votes
3answers
426 views

How to sort first two numbers in sublists

Given t7 = t8 = {{3, 5, 1}, {19, 2, 9}, {4, 3, 1}, {19, 0, 8}}; I want to Sort the first two numbers in each sublist and keep ...
2
votes
1answer
58 views

How to plot a double log scale at the x axis?

I need to plot my Data with a double Log Scale on the x axis. So basically apply ListLogLinearPlot two times. Does anyone have any ideas how to do that?
0
votes
2answers
55 views

Selecting Keys when Lists are used as Keys

Analyzing a sequence after restructuring it, Counts returns a sequence similar to below: ...
1
vote
0answers
65 views

How do I carry out a partial row reduction of a matrix? [closed]

I have a large matrix with more columns than rows. I have attempted to row reduce the matrix using Mathematica's RowReduce command. I have been able to do this ...
0
votes
3answers
76 views

2d Binning of event-lists

I have a large file (list) with events, each of which contains many observables and is thus a list by itself. The structure of the event list is then as follows: {{a1,b1,c1,d1,...},{a2,b2,c2,d2,...},.....
1
vote
1answer
65 views

Appropriate syntax for constructing frequency table and histogram from experiment with three or more dice?

if I say to input 3, how do I get MMA to make me a table with all the cases on the left, in the center their frequency and on the right a histogram,bar chart, or some other way to represent the above. ...
2
votes
1answer
52 views

Ordering is not able to sort eigenvalues correctly! [closed]

I have a matrix as below one: ...
0
votes
0answers
59 views

Evaluate a function with 3 different variables for the whole list of each variable

I have a function with 3 variables f[t1,t2,t3] Each function has a list of values ...
1
vote
1answer
58 views

Collect data only for odd positions [closed]

I have data set, say, list={{x1,y1},{x2,y2},{x3,y3},{x4,y4},...,{xn,yn}} How can I construct the following list ? ...
2
votes
2answers
209 views

How to create a 2D mesh along a specified path?

I am trying to create a mesh along specific lines connecting specific points. Here I used Subdivide to create n steps along the ...
-1
votes
1answer
72 views

Costly function inside nested Modules [closed]

The function initDataTable simply reset all data to Black first, then set the bottom right quarter to ...
3
votes
3answers
150 views

How to produce {{1,40},{2,20}} from {{1, 10}, {2, 20}, {1, 30}}?

My attempt below produced a warning: Total::normal: Nonatomic expression expected at position 1 in Total[y]. ...
4
votes
2answers
430 views

Is there any simpler way to generate dominoes?

I want to make a list of dominoes. My attempt is as follows. Subsets[#, {2}]~Join~Thread[{#, #}] &@Range[0, 6] {{0,1},{0,2},{0,3},{0,4},{0,5},{0,6},{1,2},{1,3}...
3
votes
1answer
149 views

Function with variable-length nested list

FromPolarCoordinates has a very nice feature: if you supply several points, e. g. {{r1,phi1},{r2,phi2},...}, it will return a ...
3
votes
2answers
154 views

Equality of two lists of complex numbers

I have these two lists of complex numbers: ...
4
votes
1answer
165 views

Find the longest sequence of "1" in a SubList

I'm trying to return the sublist(s) with the longest sequence of 1, although my code is working in a majority of cases, there are exceptions that I don't understand . Example: ...
1
vote
1answer
68 views

Picking/selecting elements from a list

I'm trying to pick/select elements from a list based on another list's value. I haven't been able to implement the solution given to similar questions, such as this and this. Here is a MWE: ...
2
votes
3answers
113 views

Exporting specific frame of ListAnimate

Imagine I have a certain list of Graphics-type objects that I then incorporate into ListAnimate ...
2
votes
1answer
56 views

Mathematica association does not work on symbols

Question about using an association within Replace. If I have an association which contains symbols like so: ...
0
votes
0answers
20 views

Applying a function to a number of variables stored as a list [duplicate]

If I have a function of several variables $f(a,b,...)$, where the variables are stored in a list {a,b,...} how do I call on the function? The following: ...
2
votes
3answers
304 views

How to ask Mathematica to subtract each adjacent pair in a list, and then, sum them?

If I have a list of numbers as (the number of elements in this list is even) list={1,23,32,54,65,76,87,98,109,110,...} How can I ask Mathematica to subtract each ...
0
votes
0answers
36 views

Finding the integer values of $p$ and $l$ for which a function $b(p, l)$ is divisible by $n$

I wrote the code in the attached image to find the integer values of $p$ and $l$ for which a function $b(p, l)$ is divisible by 3. Does anyone know of a nicer way to achieve the same result? Perhaps ...
0
votes
1answer
42 views

Construct a matrix from a given data set and perform subsequent operations

I have data set, say, {${x_i, y_i}$} where $i$ varies from $1$ to $n$. Now, how can I construct the matrices $M_i=\{\{1,x_i,x_i\},\{\ x_i,1,y_i\},\{x_i, y_i, 1 \}\}$ and perform the following ...
1
vote
1answer
28 views

Automatically retrieve evaluation spot row number

Suppose I need to define a matrix of the form {{a, b, Reduce[a<b]}, {c, d, Reduce[c<d]}, {e, f, Reduce[e<f]}} but with a lot more rows and automating the ...
2
votes
1answer
62 views

About patterns with typed data

I have a difficulty to define the pattern to obtain this result: ...
0
votes
1answer
67 views

Does default 'Sort' generate always the same result? [closed]

Does default 'Sort' output always the same result regardless if we change its order? Suppose that L = {E1,E2,E3,E4,E5} (*here E1,..,E5 means any possible ...
3
votes
1answer
116 views

Why do these two calls to Apply return different results?

In the following example, why do these two calls to Apply return different results? ...
0
votes
2answers
87 views

Order multivariable polynomial terms in order of total degree

Given a polynomial, lets say for example $f(x,y) = (1+x+y)^2 = 1+2x+x^2+2y+2xy+y^2$, I'd like to be able to order the terms of the polynomial by total degree, either in increasing or decreasing order (...

1
3 4
5
6 7
148