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
6
votes
2answers
319 views

Riffle multiple lists together

I'm trying to write a function which will take multiple lists of function parameters and riffle all of their parameters together as input for a function. To be more explicit, consider if I had the ...
-1
votes
0answers
32 views

Forming a list of planet densities

I have a code that gives me 7 exoplanets: ...
0
votes
1answer
73 views

Integer values only from a TABLE output

how can I only show the integers values of this Table data? Like I don't want to see all the other imaginary values displayed even. ...
2
votes
1answer
49 views

Stop `(Parallel)Table` evaluation when wanted case is found

I have to go through a long list of evaluations, for which I suppose Table instead of For or ...
0
votes
1answer
41 views

Using Count and Rotate left

Q. Use RotateLeft and Count to find the number of planets detected by each method, presenting the result in a list of the form {{D, n1}, {R, n2}, {T, n3}}. ...
1
vote
1answer
66 views

How to use Map inside Select

Input: Select[Range[10], 2 <= # <= 5 || 8 <= # <= 10 &] Output: {2, 3, 4, 5, 8, 9, 10} In case I have lots ...
4
votes
1answer
32 views

DeleteDuplicates DeleteDuplicatesBy used in a specific situation

How to use DeleteDuplicates or DeleteDuplicatesBy to delete duplicates inside list if I want to treat non-identical numbers, say $1$ and $2$ as identical? I would define list of rules for identical ...
2
votes
2answers
45 views

ListLogPlot with uncertainties in both coordinates

I have a dataset like this: ...
2
votes
1answer
109 views

list sorting task

I am trying to understand how to sort by multiple columns in Mathematica. Here is a simple data set consisting of results of sports matches. Each element represents a game, and contains fields for ...
3
votes
2answers
94 views

Using Map to extract elements of a list

I am given this problem. ...
0
votes
1answer
31 views

Making substitution to an expressions with a list of numerical data [closed]

Suppose I have an expression similar to this: y=23.23*(h[x]^2)*(D[h[x],x])*(D[h[x],{x,3}])/(13.2+Cos[0.245x]) The actual expression is a lot more complicated, but ...
1
vote
1answer
49 views

Manipulating two list into a single list of two dimensions [duplicate]

I have a list A = {1,2,3} and B = {4,5,6} Is there a quick way to produce C out of A and B such that ...
7
votes
5answers
1k views

how to drop the second curly bracket?

I would like to modify the following List: vtable ={ { {0,{0}},{0, {1}}} ,{{1,{0}},{1,{1}}} } as follows: ...
2
votes
1answer
39 views

AppendTo inside ParallelMap

I think this question has never been fully answered. In here the problem has already been mentioned, but let me give a MWE. I will solve a given ODE for a wide range of initial conditions and I want ...
10
votes
4answers
431 views

Delete sublist when sub-sublists contain same element

Given lis={{{a},{b,c,d}},{{a,b},{b,c}},{{b,c},{a,b,c}},{{b},{d}},{{a,b},{c,d}}} I want to delete sublists which have one or more elements in common. So that I ...
5
votes
1answer
53 views

Creating a dynamic list of parameter defined functions

I'm trying to create a list of functions that is dynamic in size and defines function names like so: ...
6
votes
2answers
178 views

How to map function f to every element

MapAt[f, {{a, b, {c, d}}, {d, {e, g, {c, d}}}}, 1] How to operate to get such a result: ...
1
vote
3answers
93 views

Make uniform grid around a specific point

I have a point (0.128531, 0.0765588) on xy plane where the range of x is {-0.678525, 0.678525} and the range of y is {0, 0.678525}. I want to make a uniform grid including the point in its center (let’...
2
votes
1answer
38 views

Export to Excel with empty cells as dilimiters

I would like to combine some pieces of data and export the data to Excel, but I need to insert some empty cells between pieces of data as the delimiter. For example, I have two lists ...
3
votes
2answers
159 views

Selecting Edges and Corners in a Mesh

Consider the following VoronoiMesh obtained after a few iterations of Lloyd's relaxation algorithm ...
8
votes
1answer
332 views

Apply a List of Arguments to a List of Functions

Happy new year, everyone! I hope this is a good one. The title doesn't really express well what I want to do, however, please see further explenation below. Say, I have a list of functions ...
7
votes
3answers
112 views

Specifying range in RandomReal

Is it possible to define the specific range of a RandomReal array for each coordinate? For example, the code ...
5
votes
2answers
452 views

Is there an idiomatic way to “merge by index” lists of the same length?

Consider listMerge[list1_, list2_] := Thread[({#1, #2}) &[list1, list2]] listMerge[{1,2,3}, {4,5,6}] (* {{1,4}, {2,5}, {3,6}} *) Is there a built-in function ...
1
vote
1answer
106 views

Automate Poisson Football Scores Prediction

I would like to automate a simple poisson football scores predictions process. I started by importing and cleaning home and away England League team tables data to work on it with Poisson ...
3
votes
1answer
38 views

Manipulate ListPlot a matrix [closed]

i am tring to plot a propagating wave function, but the instead of function i have points. so i have a n*n matrix (TTpsi) that i want to plot each row separately. The wave is "propagating" when the ...
5
votes
2answers
89 views

joining adjacent elements by rule

I have a list of strings: lis = {"a","1","c","ef","g","2"} and would like to join all adjacent non-numeric characters to produce: ...
1
vote
1answer
75 views

converting a raw string into a Mathematica list

I have a set of data consisting of daily measurements of two parameters. The data is available as a list of strings. Different parameters are measured each day. In the sample below, on January 1, a ...
4
votes
1answer
135 views

How to combine a lists of two lists with a list of two lists of lists of varying length?

This is probably asked before but I don't know how to begin searching for it. Some context: I'm using TemporalData objects that share a number of common features ...
15
votes
3answers
591 views

VoronoiMesh as a TogglerBar

Is it possible to use a VoronoiMesh to define a TogglerBar or SetterBar type ...
3
votes
2answers
137 views

Switching from AppendTo to Speed up

I'm trying to speed up my Code, but I'm facing problems with changing the AppendTo section in my code with something "Faster". I've read through some other ...
1
vote
2answers
58 views

Keep important eigenvectors according to the important eigenvalues except one unimportant eigenvalue

I have an iteration whose steps extract a matrix with any possible dimension for example 3*3, 6*6, ...
5
votes
2answers
375 views

Using Table Recursively

I wonder if it's possible to create a list with Table from entries of the list itself. That is, as I'm creating the list, I append a new element as a function of ...
1
vote
1answer
32 views

Preserving the headings when exporting a table

I have the following SparseArray: ...
0
votes
1answer
17 views

Error messages generated in a table calculation prevent “good” elements of that table being accessed

If I make a batch fitting routine, something like: ...
16
votes
4answers
582 views

Avoiding zeros in ArrayReshape

Consider the list list={1,2,3,4,5,6,7,8} and imagine I wanted to change it to {{1,2,3},{4,5,6},{7,8}}. How can I do this? Using ...
0
votes
3answers
64 views

Converting local degree of freedom to global degree of freedom (Manipulating a list) [closed]

I want to convert the local connectivity matrix to the global one as follows. Consider two quad elements with connectivity {{1,2,3,4},{2,5,6,3}} Now let's say ...
3
votes
2answers
55 views

Deleting a Rule according to the first element [duplicate]

I have a list of rules. Among them, I want to delete those rules which have first elements already shown up earlier. Following is a working example. ...
0
votes
1answer
39 views

Sorting a list according to the position of elements

I have a list of elements, which I want to sort according to the even/odd numbered positions of elements. Basically creating two lists out of one, respectively having elements placed at even/odd ...
5
votes
2answers
113 views

How to find the all positions of first element and get the elements at once from the nested list?

I have two questions. Let's think the following expression. expr = {plus, {minus, 2, 3}, {times, 1, 2}} Q1 I want to get something like ...
9
votes
6answers
422 views

Reversing Grouped Lists

I apologise in advance if this is a duplicate. I have looked at this question, yet have been unable to figure out how to use it when it's not nested: Link. I have a grouped list of random words <...
8
votes
1answer
225 views

Determining moving ratios over a list

To know how fast values in a list approach 1 I tried #[[1]]/#[[2]] & /@ Partition[{5040, 1460, 280, 76, 16, 2, 1}, 2, 1] This works, but I seek a better ...
11
votes
4answers
323 views

What is the optimal way to create a recombined version of two lists?

I would like to randomly recombine two lists of the following form: l1 = {a,b,c,d,e,f} l2 = {1,2,3,4,5,6} Where their recombination is similar to that of DNA, so ...
2
votes
4answers
111 views

Convert a list of list of numbers into a matrix of 1s and 0s

I want to take a list of list of integers and convert them to a matrix of 0s and 1s where an element of the matrix is 1 if "the row is in the column". The row corresponds to an integer in the list and ...
3
votes
2answers
76 views

Finding all the binary bit strings of a given length

I am new to Mathematica, this forum and programming in general. I m trying to fulfill a given task. I want to write a function, which takes as input an positive integer, say $n$, and returns a table ...
9
votes
5answers
348 views

Simple way to group the list-indices of equal elements?

I am looking for a simple way to group the list-indices of equal elements of a list. Examples: ...
6
votes
2answers
142 views

Partition list overlapping into N sub-lists as evenly as possible

There are similar questions here I haven't seen one where the there is an overlap. The requirements: The result should be N sub lists with the overlap specified. There should be no dropped elements ...
7
votes
2answers
293 views

Change part of a list

I'm starting in Mathematica. I would like your help to solve the following question (which is really basic): Whenever the sequence 1, 2, 1 appears in a given list, I want to change this part of the ...
1
vote
1answer
38 views

Display indices of the list [closed]

data = List[RandomVariate[ExponentialDistribution[2], 200]] // Sort; list = List[Table[i, {i, 0, 200}]]; d2=Riffle[{data},{list}] Partition[d2,2] This gives me ...
1
vote
2answers
54 views

How can I multiply the elements of a list using loops?

{1,1,1,-2,1,2} How acn I multiply the elements in the list using loops?
6
votes
1answer
93 views

Combine list elements preceding a specific element

Consider the following list: {"END", "END", "a", "b", "END", "p", "q", "END", "t", "END"} I want to combine elements that precede the marker element ...