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.

2
votes
2answers
39 views

selective deletions from list

I have a list: lis = {{"b","x","d"},{"a","z","b"},{"a","x","b"},{"a","x","c"},{"b","z","d"}} Certain consecutive elements of this list will have identical first ...
0
votes
1answer
54 views

Use iterator outside of iteration

I want to Map something that is depending on an iterator from the outside of e.g. Table into the procedure. What would be the ...
0
votes
0answers
41 views

Using List to create lists of strings: difference(s) between two one-line codes?

In the Virtual Book of Mathematica, there is a simple example to show how to create lists of strings by List: ...
1
vote
2answers
59 views

How to multiply out the same lists [on hold]

If I have a list of the following form: {1,1,1,0,1,1,1} How can I create a list containing 5 of these lists ie: ...
2
votes
1answer
41 views

ReplaceAll rules for Power function

I have the following function: eW = fL11(u1L^r + u2L^r) + fM11(u1M^r+ u2M^r) + fH11(u1H^r + u2H^r) The full form of eW is then: ...
9
votes
3answers
246 views

Min and Max of a list of Associations

I am trying to find the minimum values for all elements in a list of associations, below is an example ...
0
votes
1answer
42 views

Count sublists containing certain strings

I have a nested list which looks like: and I would like to count the following: all sublists containing {n_,n_} && {n_,n_,n_} all sublists containing {l_,l_} && {l_,l_,l_} all ...
1
vote
1answer
52 views

Re-nesting flattened lists

I have a function that generates nested lists of the following form: ...
0
votes
1answer
63 views

Access Large Array with Preassigned Index

I wish to use a preassigned variable to index a large array many times. For example: a = {i,j+1,k-1}; b = {i+1,j,k-2}; I know I can do this several ways but for ...
0
votes
0answers
12 views

NDSolve: Method of Lines: same grids for spatial discretization: error: stiff system_zero step size

How can I modify bbgofrey's answer so as to use $n+1$ grid points for variable $y$? My code ...
3
votes
3answers
68 views

Replacing a column of a matrix

I want to replace a column of a matrix. The best I've been able to come up with is ...
3
votes
3answers
221 views

List Interval Sum

I am doing a large data-set computation. Among those computational steps, in one step I need to do a sum with a pattern: Sum the elements with same interval. For example, for a list from 1 to 9; ...
3
votes
1answer
63 views

TakeList of a Dataset

Check this out I want to split the Dataset for graphical reasons, like creating a nice composition on a page, TakeList should ...
1
vote
2answers
49 views

Extracting first 2 elements of table

I have a table in Mathematica as follows: table1 = {{2,4,51,2017},{20,5,21,2018},{300,1,22,2016}} From this, I was wondering how one could extract only the first ...
1
vote
2answers
49 views

Numerics & List Manipulation:ListCorrelate: yield $\{-f1 + f2, \dots, -f2 + f4, \dots\}$ from $\{f1, f2, f3, f4, f5\}$

The command ListCorrelate[{-1, 1}, {f1, f2, f3, f4, f5}] yields {-f1 + f2, -f2 + f3, -f3 + f4, -f4 + f5} is there any simple way to get {-f1 + f2, -f1 + ...
2
votes
2answers
94 views

Efficient way to join elements under a conditional

I am solving a certain challenge given by my friend. I want to print the first day of the year if it is not a leap year, while I want both first and second days if it is a leap year. I want to know ...
0
votes
4answers
62 views

How to check if every element of a list satisfies a condition inside an IF construct?

I have the list, listx = {{0., -0.6}, {0.08, -1.}, {0.16, -0.9}, {0.24, 1.}, {0.32, 0.6}} And I want to check if every second element satisfies both conditions ($...
3
votes
2answers
61 views

Dropping lists using pattern [duplicate]

I have the following list of lists. data = {{0, 0, 0}, {1, 0, 0}, {2, 0, 1}, {3, 0, 0}, {4, 0, 0}, {5, 0, 3}} I want to drop all the lists with ...
0
votes
0answers
21 views
13
votes
2answers
645 views

Delete with multiple indices is extremely slow--workaround?

Delete is unbelievably slow when deleting multiple elements from a non-packed array. Is there a robust workaround that will work on any non-packed array? ...
3
votes
2answers
149 views

Basis enumeration of large lists

I want to combine two list in the following way without using Table or any loop structure. ...
0
votes
1answer
55 views

Splitting and manipulating lists

I have the following lists: ...
5
votes
4answers
425 views

Sorting a list while keeping its correspondence to another list

I have the following two lists: ...
2
votes
1answer
83 views
2
votes
1answer
22 views

combine a list with && [duplicate]

I have a huge list of the form {a==1,b==2} I want to get the expression like a==1&&b==2 How is it possible to do ...
2
votes
3answers
68 views

How to create a list of six unit vectors in 3D?

I want to have a list {{1,0,0},{0,1,0},{0,0,1},{-1,0,0},{0,-1,0},{0,0,-1}}. How to generate it smartly?
1
vote
1answer
41 views

How can I know the value of parameters?

In the the attached image I plot two function for the parameter $a1, a2, a4$. I take $a2$ as particular value, $a1$ as discrete set and $a4$ continuous value. In the plot how can i recognize for which ...
2
votes
1answer
86 views

For loop within GeoGraphics

I'm trying to plot a map with a list of destinations as Disks. I first input the cities into a list such as: ...
4
votes
1answer
67 views

String Join but not fully

Suppose I have the following string list: l={{"a","dog"},{"the","pen"}} how can I turn this to {{"a dog"},{"the pen"}} I ...
3
votes
4answers
102 views

Testing intersections in a list

In the following list {{1,3,5},{2,4,5},{3,4},{1,5}}, two elements have an empty intersection. This is not the case of the list ...
3
votes
2answers
146 views

How to drop certain elements in certain positions from a list using drop function

a = Table[i, {i, 1, 10}] Drop[a, {5, 8}] If go with the above procedure, It will delete all the elements from between position 5 to 8. How to drop elements which ...
0
votes
0answers
19 views

ListLinePlot Manipulate only discrete values in Slider

When you use a slider control for any kind of list plots slider should only take integer values and I can specify that with start point and end with step size. However, you can expand the slider and ...
1
vote
1answer
31 views

Multinomial must receive a machine size number

I need to use the multinomial distribution. In a certain step, by coincidence, the input probability vector is ...
5
votes
6answers
423 views

How to multiply nested lists by a list with the same length?

Here's the expected output: {{a, b}, {c, d}, {e, f}} * {3, 4} = {{3a, 4b}, {3c, 4d}, {3e, 4f}} However, the code above will multiply each element of the ...
3
votes
2answers
110 views

How to generate a “value-frequency” table with random numbers?

I want to create a "value-frequency" table from the following expression. Counts[Sort[RandomInteger[{1, 5}, 500]]] // TableForm The generated table should be in ...
1
vote
2answers
51 views

Building a sparse array from given lists the 2nd case

Similar to the 1st case, now given a list ...
1
vote
1answer
20 views

Building a sparse array from given lists

Given some lists ...
-1
votes
1answer
50 views

Problem with Do [closed]

Good day, I want to assign some values in a list as in the following way: The problem is that when I run the program, it does not assign any value to alpha. Does anyone know why? Thanks for your help
1
vote
2answers
66 views

Quick cursoring and replacement over a list

I have an initial list which is partitioned as follows. ...
2
votes
0answers
35 views

Fold/ NestList/ etc in MCMC loop for optimisation

I am trying to simplify and optimise an old loop code I wrote. Since Fold and NestWhile use the results of the last iteration in the new iteration, I would like to use them in order to get rid of Do ...
1
vote
1answer
21 views

Splitting a list of letters into subsequences starting with uppercase letters [duplicate]

Given a list of upper/lowercase characters, I'm trying to split it into subsequences that start with an uppercase and contain the next few (not necessarily positive number of) elements up until the ...
1
vote
2answers
55 views

Plotting two lists

I have the following lists: ...
2
votes
2answers
42 views

Flattening a list desiring a specific format

Suppose I have the following list: l={{{1},{2}},{{3}},{{4},{5}}}; How can I flatten this such that I get: ...
2
votes
2answers
148 views

How to find second,third,etc maximum peak of list

I need to find all values of peaks. I have Table with 10000 elements in it and I plot a graphic using ListPlot. Then I tried to ...
1
vote
1answer
29 views

Replacement into a list

I have the following polynomials: pol = {x^2 + 2 x^3 + 4 x^7, x + 2 x^5 + 4 x^6, 3 x^6 + 2 x^9}; and following list ...
0
votes
0answers
39 views

Finding a line intersection

I have the following list of rational functions: ...
0
votes
1answer
29 views

Making a List For Use in an Integral

I have an equation of the form $R_{min}+t= R_{min}\, e^{R_{min}}$ where for every time $t$ there is a corresponding position $R_{min}$. How can I complete the integral $F(t)=\int_{R_{min}(t)}^{r(...
4
votes
1answer
145 views

Efficient way to add new rules to a sublist within a nested list of rules

I often build nested lists (as a way to keep data sets organised) with some form like: ...
4
votes
2answers
134 views