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

learn more… | top users | synonyms (3)

2
votes
4answers
743 views

ListPlot multiple datasets over same x-values

Is there a better way to enter my data into a list plot? ...
5
votes
4answers
246 views

How to split a list with respect to its nested sublists?

I have a problem with the following task: having some nested list list = {{k6},{k1,k3,k5},{k7}} I would like to replace all sublists by their permutations and ...
2
votes
6answers
215 views

Manipulating List

I have a list: b={{1, 1}, {2, 2}, {3, 3}, {5, 5}, {6, 6}, {8, 8}, {10, 10}} I want to insert the elements in this list: ...
1
vote
0answers
72 views

The number of real values assumed by combinations of complex roots of a decic

Define complex conjugate as the pair of complex numbers $a+bi,a-bi$. Assume you have 5 such pairs and they are the 10 roots $x_i$ of a 10th-deg equation with integer coefficients. In general, how many ...
6
votes
9answers
748 views

combining and comparing lists

I have 2 lists (of lists), where most of the contained lists match. That is, the lists contained in list1 mostly match the lists contained in list2. In this simplified example each of the inner ...
14
votes
5answers
365 views

Partitioning a list of numbers the Mathematica way

I have two sorted lists, one list will be called the "fences" and the other the "values" Fences could be: $\{1, 5, 9, 14\}$ Values could be $\{-1, 1, 3, 4, 6, 9, 10, 13, 14, 15\}$ I want to ...
1
vote
4answers
222 views

Add Brackets to a string list

Hello stackexchange community! I have a stringlist with a value and his error for eg: {{"12","1"},{"13","2"}} Now i want to output this as something like this ...
3
votes
4answers
229 views

Pattern matching in nested lists

I'm sure this has been asked before, but I can't find the right combination of search keywords to find it. Apologies. I want to do a ReplaceAll on a list of lists, ...
3
votes
2answers
137 views

How to partition a list according to a nested table structure?

This question is related to this quesion. The goal is to use ParallelMap to map a function to a nested Table to get the ...
-1
votes
1answer
193 views

Efficient Table Generation & NDSolve Error

I'm currently working on solving an SEIR model with data from the CDC. I've created a function to calculate the Square difference for the model and want to create a table of values for the 4 variable ...
3
votes
3answers
143 views

Lists - pairing up

I have two (fairly large) lists of equal length & would like to pair them up. eg - from: a = {{0, 1}, {0, 2}, {0, 3}}; b = {{1, 2}, {1, 3}, {1, 4}}; I would ...
1
vote
3answers
261 views

Matlab-style Find in Mathematica? Value list and Boolean List, how to select values according to the boolean list?

I want to select elements with the true value (Indices list) in the corresponding point to the value list (MCS). Is there anything like Matlab-style Find to get the indices of true values in the ...
1
vote
3answers
104 views

ArrayRules for a ragged list

Let there be a sample list as , l = {a, {{b, c}}, {d, e}, {f}, {{g, {y}, u, h}, {{{{k, j}}}}},k, {{{{q}, {w}, {r}, {x}}}}}; ArrayRules[l] ArrayRules::rect: ...
2
votes
1answer
105 views

Putting values into a grid after iteration process

I'm developing a model of thermodynamic cycle in Mathematica. I wrote several functions, applied them to a list containing starting values and iterated, for the model to converge. ...
6
votes
5answers
250 views

Removing reverse versions of lists from a nested list [duplicate]

I need to remove the reverse versions of lists from list of lists. I.e.: {{1,2},{2,2},{2,1},{a,1,2},{2,1,a}} I need to reduce to ...
12
votes
4answers
380 views

Equivalent Nested Loop Structure

Consider the following examples: ...
3
votes
2answers
137 views

Change all values of a series to positive values

I would like to change all values of a series to positive values. I refer to my previous question, answered in the most part, very elegantly by RunnyKine. However, there remains a slight glitch that ...
3
votes
3answers
95 views

Filling in explicit zeros in a (x,y) list for nonexisting y values for discrete Fourier transform in Mathematica

I have a list of (x,y) values in Mathematica for various discrete x values, as in ...
4
votes
1answer
167 views

List manipulation - various

Update OK, Please forgive the messiness of this, but I am working with something like: ...
0
votes
0answers
27 views

Eliminate some value from a matrix [duplicate]

I have a function that return a table consisting of a 2D points. These points are either {x,y} or {0,0} ...
2
votes
4answers
144 views

Looking for mismatches between two lists

I'm able to do what I need, but it seems like there's always a better way. I have two lists, epiExcel and epiDB. Each has 3 columns and about 2,500 rows. I need to find out if the first 2 columns ...
1
vote
1answer
135 views

Replacement variable in list plot

I would like the replacement: /. {ComplexInfinity -> 0} to be treated as a variable. I am trying to overlay the following list plots: ...
10
votes
1answer
374 views

Two ways of map a function on the list: Which one is faster?

There are 2 ways to make a function listable on the list: Use Map or use SetAttributes. My question is, which one is faster, ...
3
votes
2answers
200 views

How to delete all rows in datafile that contain a string

I'm importing some data from a file. However, the file was created by an unreliable instrument, such that the data looks like this: ...
3
votes
3answers
91 views

How to get different items in a list to interact to get a result?

I have two lists, for example (the real lists are much longer): list1 = {1, 2, 3, 4, 5, 6, 7}; list2 = {9, 10, 11, 12, 13, 14, 15}; I want to create a single ...
5
votes
3answers
162 views

Preserving a bijection between arrays when shuffling elements in one array

Imagine I have two lists of elements like the following: listOne = RandomReal[{0,2}, {100,2}]; listTwo = RandomReal[{0,2}, {100,2}]; Let $f: X \to Y$ be a ...
5
votes
2answers
260 views

Provided an array of 2D point clouds, can we quickly replace distance- and index-based cliques of points with their median or mean values?

Imagine I have $N \approx 10^5$ clouds of points in an array of the form: UPDATED ...
12
votes
9answers
758 views

How to partition a list of numbers in two lists of numbers such that each lists elements sums up to the same number?

I have the following list of squares. {1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256} Their sum is $1496$, I want to make two partitions ...
0
votes
1answer
41 views

Pruning coordinates in subarrays of a list conditional on them having non-real components

If I have a list of 2D coordinates placed in subarrays of a data structure like the following: ...
1
vote
2answers
430 views

Swapping elements of list

Say I have a directed graph inputted in the following format in Mathematica: g = {{1, "a", 2}, {2, "b", 1}} I'd like to plot this graph using ...
1
vote
2answers
125 views

Quickly pruning elements in one structured array that exist in a separate unordered array

I have two lists, which we'll call testList and modifiedTestList. The first list looks something like this: ...
3
votes
2answers
189 views

Variable length list with # and [[i]] as elements

I need to create a list that as an input receives the number $N$ of elements that it will contain and that returns: ...
1
vote
1answer
108 views

Reading between blank lines in external data files

I have an external data file with several columns and thousands lines of data. For the sake of this question, let's assume that we use ...
4
votes
5answers
256 views

Can I generate a “piecewise” list from a list in a fast and elegant way?

Suppose we have a number list a: n = 1000000; a = RandomReal[{0, 1}, {n}]; We want to generate a list ...
8
votes
4answers
1k views

Removing empty sets from lists

If I had a list, say, names= {"Andy", "Bob", "Carly", "Sandy", "Jeff", "Tim", "Tom", "Zach"} and I decide to pick a characteristic only a certain of them have, ...
0
votes
1answer
151 views

How do you find the longest sublist within a nested list

Say, I have a list stuff={{eat,tea,now},{how,did,you,say},{the,cat,ate,was,can},{win,din,sin}} I have a nested list and I want to find the list that has the most ...
3
votes
1answer
652 views

Plotting multiple lists of complex numbers

The user #Nasser showed an elegant way to plot complex numbers: ...
7
votes
1answer
220 views

Visualizing nested lists for easier human understanding

When interacting with Mathematica, I often find myself staring blankly at waves of curly braces, trying to understand how data is organized hierarchically. For example, the beginning of the result to ...
5
votes
1answer
241 views

Efficiently searching a list for the position of the closest number to a specified number

Searching by closest and position I wasn't able to find an answer—but found Nearest by guessing. Nearest, however, returns ...
7
votes
1answer
380 views
8
votes
5answers
261 views

Refer to next element of list when iterating using Map [duplicate]

Is it possible to refer to the next element of the list when I'm using Map or should I always use For in this case? For example ...
2
votes
2answers
178 views

How to replace data in a list (tree) in a functional Mathematica way?

I have list containing 2D points in various groupings, i.e. points, lists of points (figures), lists of lists of points (patterns) and finally a list of patterns. The list also contains other data, ...
6
votes
2answers
158 views

Extract urls from list

If I have a list like list = {"my element 1 http://link.com", "http://link2.com my element 2"} how do I get a list of the links inside each element? Something ...
1
vote
0answers
38 views

How can I access numerical values of variables calculated with Solve? [duplicate]

I am trying to calculate some thermodynamical cycles so I often use lists with equations. Here's a simple example: ...
3
votes
2answers
107 views

Manually accept elements of a list

Let's say I have a list like: {"good element 1", "bad element 1", "good element 2", "good element 3", "bad element 2", ...} I would like to build a function that ...
0
votes
0answers
45 views

How to manipulate lists to get only part of the value [duplicate]

This is really a question about manipulating the output of Maximize. I have a function of 2 variables, defined thus: ...
1
vote
2answers
187 views

How do I find the most populous cities in the world?

I am attempting to plot the most populous cities on a world map. Currently, I have the line of code: ...
4
votes
1answer
146 views

What is the equivalent of MATLAB's “timealign” function?

What is the equivalent of MATLAB's "timealign" function? Given two sequences (lists of values) and offsets, timealign will insert 0's into sequences to align them so they have the same number of ...
1
vote
1answer
204 views

Split Lingustic(IPA) at Words Unique Sounds

How might I split a word at each IPA of each unique sound. For example {"pray", "wade"} (* {{"p","r","ˈeɪ"}, {"w","ˈeɪ","d"}} *) ssch answered a question here ...
6
votes
3answers
184 views

Using PatternTest and/or Condition to detect equal list lengths as well as list element formats

On searching Mathematica.SE for information about overloading functions, I came across several threads about PatternTest and ...