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

learn more… | top users | synonyms (3)

0
votes
1answer
38 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
328 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
116 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
179 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
95 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
4answers
217 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 ...
6
votes
4answers
654 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
116 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
368 views

Plotting multiple lists of complex numbers

The user #Nasser showed an elegant way to plot complex numbers: ...
5
votes
0answers
164 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
192 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
287 views
8
votes
5answers
220 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
159 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
156 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
37 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
105 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
42 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: ...
0
votes
0answers
35 views

How do I plot cities on a Map? [duplicate]

Right now, I have the 20 cities with the most population in the world, given by the lines of code ...
1
vote
2answers
140 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
139 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
177 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
163 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 ...
0
votes
2answers
107 views

Where are the functional programming constructs: `every` and `some`? [duplicate]

Coming from other functional programming environments (e.g., Clojure) I've become accustomed to some functions that I haven't found equivalents for in Mathematica yet. The two I reached for last ...
7
votes
3answers
215 views

How to Flatten Array of Arrays of the highest order in a simple way?

I have a matrix of matrices, given in the following code. I want to flatten the array... ...
11
votes
1answer
173 views

How to find longest monotonic sequence?

I have a list, for example list = {2, 1, 3, 5, 4, 6} How to find longest ascending sequence of this list? There are two meanings of this question: Find the ...
2
votes
5answers
203 views

Treat list as cyclic

I am considering the following case. Say that T={p1,p2,p3} represents a triangle. In addition, I want to parameterize the edges of the triangle ...
2
votes
1answer
104 views

How to make an efficient difference of sets function?

How to write a nice code that removes all elements from given set A, that occur also in set B? I would like to use DeleteCases[] for this purpose, but have no good ...
0
votes
2answers
149 views

NestWhile application

I have the function which take the last list in nested list, reduce it somehow in several ways so the length of list reduces and output new list wherein input list appended with defferent reduced ...
3
votes
7answers
331 views

Concise way to generate multiset lists

I wrote the following to generate a multiset with the same number of items over a fixed range: ConstantArray[#, 3]& /@ Range[9] // Flatten ...
0
votes
1answer
121 views

Adding labels on ArrayPlot and coloring rows

I need to add lables on the right from ArrayPlot for each row and color the black square of each row depending on values from two list. Color list has a numbers in some range and should be mapped ...
1
vote
1answer
169 views

Formatting plot of symmetric points differently to asymmetric points

From an array of numbers, I would like to determine (and then colour appropriately) which points are symmetric about a given axis (here, $x = 1/2$), and which are not. For example, form this: ...
3
votes
1answer
192 views

MapThread Alternatives

I want to add two matrices, the first one containing a 2D vector at each position the other one a list of 2D vectors. The 2D vector from the first matrix should be added to each of the 2D vectors at ...
5
votes
4answers
193 views

Group list of lists by Total

I have some list which looks like {{0,1},{4},{0,0,1},{2,0,1},{3,0,0},{3,1},{0,0,0,4}} and I need to group lists with equal sum of elements in ascending order ...
3
votes
2answers
131 views

Write list of polynomials as a matrix of coefficients times a list of monomials

I have the following problem: given a list of polynomials P = {p1, ..., pn} on the variables x[1], ..., x[n], find a list of ...
0
votes
1answer
260 views

How can I combine several 2D-plots to one big 3D plot?

So I've been able to make a list given by list = Table[{xValues, f[xValues, t (*fixed*)]}, {xValues, xmin, xmax}] For example: ...
0
votes
0answers
24 views
0
votes
2answers
118 views

Problem with Select and Pick

I want to filter a data file choosing those elements that match a condition and then plot them. Here is the corresponding code I use: ...
1
vote
4answers
151 views

Can I combine two FoldList into one?

I want get something like this: {{x, x}, {g[x, 1], f[x, 1]}, {g[g[x, 1], 2], f[f[x, 1], 2]}, {g[g[g[x, 1], 2], 3], f[f[f[x, 1], 2], 3]}} one way is ...
18
votes
3answers
721 views

Strip waste braces in nested list

I have nested lists wherein there are a lot of waste levels which looks like l = {{{{{{2, 2}}, 3}, 2, {{2, 33}}, 4, 5}}}; I would like to reduce it to somthing ...
-3
votes
3answers
180 views

Statistical analysis of a data file and its Plot [closed]

As the title says, I have an external data file which contains thousands lines of data. The data file contains eight columns and here is what I would like to plot: Let's assume that the length of the ...
5
votes
5answers
320 views

Counting function, comparing lists

Update I would now like to produce a plot that explores the difference between the squarefree count and the expected mean (without using SquareFreeQ) - something along the lines of: ...
11
votes
11answers
437 views

Replace elements in list not matching elements of another list at the same position

I would like to compare two arrays: m = {a,b,c,d,d,f}; n = {b,b,a,d,d,e}; and get: {0,b,0,d,d,0} I have tried all kinds ...
2
votes
1answer
378 views

Newton-Raphson Method and the Van der Waal Equation Coding question

So I need to find Specific Volumes using the Newton Method from the Van der Waal equation over a change of constant Temperature but variant Pressure. I have been able to make a list of however many ...
1
vote
2answers
101 views

How do I operate on this list elegantly? [duplicate]

calibData = { {200, 10}, {100, 20} } MapAt[N, MapAt[Log10, calibData, {;; , 1}], {;; , 1}] I want to apply a base 10 Log to the first element of each tuple. ...
2
votes
0answers
195 views

Taking real and imaginary parts of indexed functions and speeding up ComplexExpand

I am setting up a large system of ODEs and in order to use the IDA method (which is sig. faster for my system and thus attractive), I must split my equations into real and imaginary parts. I am ...
2
votes
3answers
91 views

List Manipulation matrices

I have the following two lists: List A: ...
5
votes
1answer
131 views

Strange phenomenon with Outer

...
6
votes
3answers
222 views

How do I find the number of countries that have a type of industry?

I am trying to find the number of countries that have a certain type of industry. Currently, I have this code: ...
0
votes
4answers
60 views

Don't understand why Do-loop index is not evaluated in Play expression

So here is some weird behavior: When I create a list inside a loop whose elements are Play functions, with arguments that depend on the counter, it is as if the counter is being stored symbolically, ...