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

learn more… | top users | synonyms (3)

0
votes
2answers
116 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
226 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
219 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
219 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
144 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
186 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
362 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
146 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
196 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: ...
4
votes
1answer
223 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
206 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
146 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
317 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
25 views
0
votes
2answers
135 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
153 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 ...
20
votes
3answers
824 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 ...
5
votes
5answers
347 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
452 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
517 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
108 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. ...
3
votes
0answers
281 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
97 views

List Manipulation matrices

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

Strange phenomenon with Outer

...
6
votes
4answers
277 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
63 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, ...
0
votes
1answer
212 views

Do loop - variable does not change [duplicate]

I got the follwing code which should add a '1' 100 times to an empty list. plotVals = {} Do[Append[plotVals, 1], {l, 1, Nmax}]; The output is again an empty ...
12
votes
10answers
683 views

Counting sublists containing 0

Given a list: data = {{0, 2}, {0, 0}, {1, 0}, {1, 2}, {2, 3}}. I would like to count the number of sublists which contain zero. ...
9
votes
8answers
664 views

Position of First nonzero number

I want to know is there any one line code to find position of first nonzero number without calculating position of all non zero numbers. For example, ...
1
vote
1answer
340 views

Row-Reduced-Echelon-Form with Equation Parameters for Consistent Systems

I often do row-reduced-echelon-form (RREF) calculations that involve parameters using the RowReduce command. Most times, I want to know which parameters make the system consistent. For example: ...
0
votes
0answers
12 views

Part::partd error on one of two similar lists [duplicate]

I have run into a problem that I can't explain. Here is the code: ...
4
votes
4answers
130 views

Expanding lists with split strings

I've got data of the type: list = {"Class","MW","10 - 11"} which I would like to split into a number of lists based on the number of characters in the second ...
1
vote
1answer
75 views

Exporting data which includes rule as number only and use lhs as label

I use listD1 = Table[FindRoot[(*my eqns depending on k*), {k, conc}] to get a list of solutions for the different values of ...
0
votes
2answers
143 views

how to export nested list

I have a ListPlot where I extract my data again using pts1 = Cases[(*I put my list plot here*), , x_Point :> First@x, Infinity]; which gives me the data as ...
0
votes
2answers
83 views

Generate higher dimensional box vectors

I'd like to generate integer vectors in $\{-M,-M+1,\dots,M\}^n$, where $M$ and $n$ are parameters. For a fixed $n$, say $n=3$ for instance, I only know I can use ...
3
votes
5answers
378 views

Elegantly adding two differently spaced lists of ordered pairs $(x, y)$

Suppose that I have two lists, list1 and list2, of ordered pairs $(x, y)$. The two lists are differently spaced in $x$; some ...
5
votes
2answers
197 views

Ranking a vector containing ties

How can I rank a vector such that the ties are replaced by their middle ranks. For example, {1, 2, 2, 3}. I want to rank this vector but the ties must be replaced ...
0
votes
1answer
100 views

Problem with List Dimension Outer Map [duplicate]

I am currently handling a big list which has the following dimension: {6, 3, 4, 2, 2, 1, 8} where the last number 8 represent a ...
8
votes
1answer
306 views

How can I define a Listable function only apply to a vector?

Consider the function f which should behave as f[{{1, 2}, {3, 4}, {5, 6, 7}}] ...
4
votes
3answers
201 views

Variable partitioning of the data in the form of “list of lists”

I am looking for a way for variable partitioning of the data in the form of a "list of lists" for interpolating the imported data from excel. The data looks like: ...
3
votes
1answer
183 views

Levels and slots

I am struggling with levels and #, if I understand this I think I will be able to grasp the entire concept. ...
8
votes
1answer
168 views

Quickly selecting for points in a set that are within a critical distance of points in another set

Imagine two lists of two-dimensional coordinates: listA = RandomReal[{0,100},{202,2}]; listB = RandomReal[{0,100},{97,2}]; I'm attempting to quickly generate a ...
7
votes
1answer
101 views

Why does Rescale performance vary significantly based on the real number values in a list?

I have a list of the form: testList = Table[{Flatten[RandomReal[{-200, 200}, {1, 2}], 1], RandomReal[{-200, 200}, {69, 2}]}, {i, 1, 100}]; And I would like to ...
4
votes
2answers
583 views
2
votes
1answer
114 views

Can Map operations be compiled or otherwise sped up for large lists?

I'm performing a series of Map operations in the following script: ...
4
votes
2answers
143 views

Speeding up Position for finding the indices of a small number of integer elements in a large matrix

I have a large $100 \times 4000$ element matrix composed of integer elements, testMatrix, and I was to use Position to find the ...
0
votes
1answer
145 views

Generating an array using list values at indices corresponding to entries in a separate list satisfying some criterion

Imagine one has an array of integer value sets that looks like this: ...
0
votes
1answer
150 views

johansen test error in code

Cross-posted at the Wolfram community forum I have found this code on a forum, apparently it worked in a previous version of mathematica. Now when I run it, it keeps running for ages. I am not able ...
3
votes
0answers
97 views

Gather dependency on list order?

I get intrigued about Gather behavior on this post. I thought that Gather was invariant under list order? Here is the result I ...
12
votes
5answers
687 views

What's the cleanest functional-programming style way to perform this list operation?

I am looking for the correct method for accomplishing the unknown piece in the following code snippet: rolls = Tuples[Range[1, 4], {2}] ...