Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [list-manipulation]

Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.

4
votes
2answers
270 views

Best use of steel bar cut for mechanical study

I have available a steel bar with length of 3000 mm. I intend to get the best use of cutting out of this bar. I need to cut this steel bar in the following lengths: 230mm, 260mm, 320mm, 350mm and ...
4
votes
5answers
220 views

How to join many columns of data in array?

I have large number of columns of data. How to put in single matrix? For example, with test data of 1 x 3 matrixs ...
1
vote
2answers
72 views

Animated Lissajous Curves Parametric Plot

I love mathematical GIFs' power to illustrate and communicate math concepts widely. I haven't had much luck with the build-in ListAnimate on MMA Online but ...
0
votes
1answer
40 views

Modification to the list of string

Suppose we have a list of the following: l={"applejuice","lemon_juiceginger"} How can one modifies this to read as: ...
0
votes
0answers
26 views

List of function - basis

I would like to define list of function (make polynomial basis as a set of the functions), and then evaluate value of first/ second function in the set. I have made set of the fuctions that I have ...
3
votes
2answers
83 views

Is it possible or how to extract message string from binarized list?

Given message copied from Silvia's profile page, a binarized list could be found bellow. ...
0
votes
1answer
65 views

DeleteDuplicates not working for a list in main program [on hold]

I have a list of dimension $ 50 \times 1 $. The list has some duplicates, I used DeleteDuplicates to delete repeated elements, which however seems not working. ...
4
votes
3answers
133 views

How to Partition rest rows by the first row?

Given a list lst = {{{"1","2","3"},{"4","5"},{"6","7","8","9"}}, { "A","B","C","D","E","F","G","H","I"}, { "9","8","7","6","5","4","3","2","1"}}; ...
7
votes
3answers
332 views

How to concatenate list of integers into a single number

Is there a way to concatenate the elements of a list into ONE number? For example, if there is a list L={13,5,8,0}, then I am looking for a way to append ...
1
vote
1answer
34 views

Precalculating ThreeJSymbols to make my program faster

Does anybody have an idea what is the best way to pre-calculate the ThreeJSymbols in order to use them in a loop? (I want to make my program work faster that is why ...
1
vote
1answer
35 views

Selecting from a matrix according to elements of a column — efficiency and speed?

I need to select all elements from matrix M that have in their 3rd column elements from some given list L (3rd column and L are real numbers). I have written the most obvious (to me) command to select ...
11
votes
4answers
687 views
4
votes
3answers
414 views

Generate this sequence more efficiently

Is there a more effecient way to generate the sequence shown below. ...
2
votes
1answer
62 views

How to set up SortBy columns in Dataset dynamically?

Given a dataset like this: ...
0
votes
0answers
41 views

Interpretation of a 1x1 matrix, rank 1 vector, and a scalar?

This is a seemingly trivial question, but I'd like to understand how to correctly treat matrices (and I guess rows/columns in Mathematica). I'm having fun figuring out how to express rows and columns ...
0
votes
0answers
27 views

Help with weird behaviour of Map[Take… on large lists

Lets say I create a giant list: tmp=RandomReal[{1,10},600000000]; Now I want to take 10 random sublists of length 150000: ...
3
votes
2answers
137 views

Removing anomalous points from data

I have two sets of 2d-data points which can be transformed in each other by using a certain transformation function. The problem is that in both data sets there are points which do not have ...
0
votes
2answers
69 views

Creating a nested table

I have a row of values that I partition into a table. row = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; rowPartitioned = Partition[row, 6] ...
1
vote
3answers
59 views

Manipulation of two lists of strings and integers

I have the following lists: ...
7
votes
5answers
310 views

Unexpected behaviour of Nothing inside List inside Association

When evaluating the following input: <|a -> {c, d, e}|> /. d -> Nothing I get (expression 1): ...
3
votes
2answers
201 views

Applying function to all elements of the list of list

Let's say we have a following list: ...
1
vote
1answer
51 views

Find and number sublists

I implemented the following routine. array1 = {12, -12, 14, 12, 1, -3, 1, 1, 2, 7, 8, 102, 2, 3, 3, 1, 332, 11, 23, 2, -2, 13, 12, 1, 1, 1, 1, 1, 1, -121, 131}; ...
5
votes
1answer
51 views

How to set up patterns when using SequenceSplit

Given a list lst={0,0,0,0,0,"A1",0,0,0,"B2",0,0,"C3","D4","E5",0,0,0,"F6"} How to split it as ...
2
votes
5answers
300 views

Reconstructing a polynomial from its coefficient array

A polynomial coefficient matrix: mat = CoefficientList[3 + 5 x^3 + 4 y^3 + 2 x + 6 x^2 y + 7 x y^2 + 8 x y, {x, y}]; \begin{equation} \left( \begin{array}{...
4
votes
2answers
75 views

Selecting elements satisfying a condition

I have a list of lists(of lists): ...
1
vote
1answer
89 views

Selecting cases from a list based on two conditions

Let's say we have a list of lists of length 3, as below: ...
3
votes
3answers
117 views

ListPlot from Table of single input x and many y(x) output

Suppose have data for several x and several y(x), for example mydata = {{11, 1.1, 2.3, 2.4}, {12, 1.3, 1.4, 1.9}, {13, 1.8, 1.7, 1.2}} mydata // MatrixForm So ...
0
votes
2answers
33 views

Finding members of the list that share a common element

Let's say I have a list: {{1}, {2}, {3}, {4}, {1, 2}, {2, 3}, {3, 4}, {1, 2, 3}, {2, 3, 4}, {1, 2, 3, 4}} and I want to find all the members of that list that ...
1
vote
2answers
31 views

Add value to nonzero elements of symbolic matrix

I would like to add a certain placeholder O to any nonzero element of a matrix. The matrix has elements which are not number but complicated symbolic expressions. ...
0
votes
0answers
26 views

How can I check if elements between lists are equal? [duplicate]

Say I have two lists: list1 = {a, b, c, d} list2 = {b, b, d, d} And I want to get the output {False, True, False, True} ...
0
votes
0answers
9 views

Create a polynomial from a list of coefficients [duplicate]

First I have to extract coefficients from a polynomial.Then I have to make a polynomial from by given list and show that they are identical. So I tried like this: ...
0
votes
3answers
73 views

Locating Points “orderly” within a cube [closed]

I have a small question about creating a 3D array of particles. It's necessary that 265 particles are located orderly within a unit cube. One hint is to use a simple cubic structure but I don't see ...
2
votes
1answer
28 views

Obtain argument of tensor product

I want to obtain the argument of a TensorProduct as a list of elements by applying another function. For example, I wish to write a function h which, when applied to a tensor product, produces the ...
4
votes
3answers
186 views

How do I use drop to drop the second element from all these sublists? [duplicate]

{{1, 2}, {2, 3}, {5, 4}} I tried to do this: Drop[#, {2}] & @@ {{1, 2}, {2, 3}, {5, 4}} but it gave {1} but what I want is {{1},{2},{5}}
1
vote
0answers
48 views

Monitoring the Training Progress through PutAppend

I would like to export the round loss during my model training for each training round. Currently, I am using the way shown in the Documentation Center around TrainingProgressFunction and PutAppend: <...
6
votes
5answers
289 views

How to do a list partition with offset, overhang, and cyclical padding? [closed]

I have a list as {1,2,3,4,5,6,7,8,9} I want to extract a new list as ...
2
votes
1answer
128 views

Function for SortBy

Let's say I have the following list ...
4
votes
3answers
259 views

Turn the following values into percentage [closed]

I have the following data: {2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017} {5914, 6143, 6182, 18000, 18173, 18344, 18454, 18506, 18800, 19216} My data is already in Matrix form in ...
10
votes
6answers
687 views

Fastest way to go from linear index to grid index

I'm sure this has been asked before but I'm interested in going from a position in a vector to the index in the grid version of the vector with given strides, for example, say I have the vector: <...
11
votes
1answer
280 views

How to determine the longest edge in a graph?

I have a list of 2D points such as in the image. coord = {{0, 0}, {10, 0}, {20, 0}, {30, 0}, {25, 10}, {0, 10}, {0, 5}}; I would like to determine the longest "...
6
votes
2answers
193 views

Delete elements of list with certain length

I have a list containing some other lists having different lengths. I want to remove some of the lists with a certain length. For example, I have ...
6
votes
4answers
215 views

Take single element of a list, and compare to average of whole list

If I have a list lst = {1, 2, 3, 4, 5}; Is there some way of taking the first element and then comparing it to the average of the other 4? Then to take element 2 ...
3
votes
1answer
105 views

Sorting of a list with different lengths

I have a list of disordered numbers. They are collected in different lists. I mean ...
1
vote
1answer
26 views

Indices of nonzero rows in a sparse array

Given $A\!\in\!\mathbb{Z}^{m\times n}$ stored as a=SparseArray[{...},{m,n}], how can I obtain the list of all indices $i\!\in\!\{1,\ldots,m\}$ for which the $i$-th ...
5
votes
4answers
720 views

How to avoid “if statement” in Mathematica?

I have a list of 100 vectors 2D (x,y) defined by RandomReal[1.0, {100, 2}] and a given forward vector such as {1, 1}. My ...
9
votes
4answers
535 views

How to remove vertices from a graph?

I have 2 lists: list 1 is a list of vertices of a graph, says, {1,2,3,4,5} and list 2 keeps track of edges (i.e which vertex connects to which) such as {{1,2}, {2,3},{3,4},{4,1},{2,5}}. Now I want to ...
2
votes
1answer
137 views

How to find a smallest value in a list? [closed]

I have a list of point2d coordinate {x,y}. I would like to find the point where x is the smallest. How can I do it in Mathematica?
0
votes
1answer
50 views

Read text files as sparse arrays and concatenate in a loop

I would like to read multiple text files and build a sparse array by concatenating row-wise one after the other. The text files are ordered in the following format: \begin{matrix} 0, & 0, &...
1
vote
0answers
47 views

How to add brackets to list [closed]

I have for example set of points p={1/5,1/2} and I would like to add brackets to the list, so I would like to get a set of points p2={{1/5},{1/2}} I know how to remove brackets, but I cant ...