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

learn more… | top users | synonyms (3)

7
votes
2answers
237 views

Programatically adding/retaining comments within a nested list

Is it possible to convert the following list of strings to computable numbers with the comments preserved? ...
7
votes
2answers
191 views

Intersection for lists of numeric data

I know that Intersection is a pattern matching function and will not evaluate list elements to determine if two or more list have equal elements. So my question is, ...
7
votes
3answers
154 views

Given a list of lists, build a list in which lists with equal first and last elements are grouped together

I have a list of lists, and I'd like to build a new list, in which lists are in the same list if they have the same first and last element. Here's an example. Suppose I have ...
7
votes
2answers
1k views

Finding all partitions of a set

I'm looking for straightforward way to find all the partitions of a set. IntegerPartitions seems to provide a useful start. But then things get a bit complicated. ...
7
votes
1answer
908 views

Get the coordinates from ContourPlot and RegionPlot

How do I get the coordinates from a contour plot I've done in Mathematica? For example, I have a two-variable function f[x, y], for which I can make a contour plot: ...
7
votes
2answers
312 views

Finding all points of period n in an iterated map

I'm trying to implement an algorithm of Jenkinson and Pollicott to calculate the Hausdorff dimension of a Julia set for the map $f_c : z\mapsto z^2 + c$. It's described on page 40 of their paper, ...
7
votes
2answers
206 views

How can I get the list of dates in the next $n$ years

How can I get the list of all dates from today 21.02.2012 (which is a palindrome) up to say next $n$ years? Then finding the other palindromes are not difficult. I could not find an easy way to ...
7
votes
3answers
363 views

Filter list based on date

What I would like to do is remove entries from a list of instrument data when it is in maintenance. The maintenance data I have is a series of dates which look like this; ...
7
votes
2answers
290 views

Building a tree

Given a list of word characters, such as this one, I'd like to build a tree, similar to this makeTree function, but with the tree in a different format. So, for an input such as ...
7
votes
1answer
94 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 ...
7
votes
3answers
311 views

Multiply a list of matrices by a list of vectors

How does one multiply a list of matrices by a list of vectors, elementwise? For example, multiplying ...
7
votes
2answers
1k views

Building matrices by attaching vectors (columns) and matrices

Having the need to attach a column to a matrix or to join matrices to make longer rows is an operation that I use very frequently and I find the Join function ideal ...
7
votes
3answers
344 views

How to Gather a list with some elements considered unique

I have a list of the form: list={{0,...},{1,...},{1,...},{0,...},{3,...},{3,...},{0,...},{0,...},{5,...},{5,...},{5,...},{0,...},{5,...},{0,...},...} So when we ...
7
votes
1answer
237 views

DeleteDuplicates[] does not work as expected on floating point values

Here is my simple example, and in this case function DeleteDuplicates does not work as expected. I want to FindRoot of my ...
7
votes
3answers
291 views

Find all the last weekends in a year

In order to obtain the weekends of a year you'd use something like this: ...
7
votes
3answers
239 views

Restricted accumulation of values

Please consider the following list data. I was trying to accumulate data until the result turns positive the first time and ...
7
votes
1answer
380 views

Very fast way to do a coordinate frame transform

I need a function that rotates and translates a huge amount of line segments. For example, I have a set of line segments in the form {{x0,y0,z0},{x1,y1,z1}} ...
7
votes
1answer
174 views

Built in way to de-list singletons?

Is there a built in method to de-list singleton expressions, like this rule-based solution: expr_ :> If[Length[expr] == 1, First@expr, expr] In data ...
7
votes
3answers
245 views

Making large tables easy to read with frozen headings and scrollbars [duplicate]

I would like to represent a table containing a large amount of information in such a way that I can (a) use scrollbars and (b) have table headings that don't scroll off the screen [just like the Free ...
7
votes
1answer
161 views

Visualize a tree structure using TreeGraph

I have a code that generates a tree of graphics objects. The structure can be visualized like this, with each Rule constituting a parent child relationship: ...
7
votes
0answers
223 views

Using Compile to speed up Function with PermutationProduct

I have the following fairly simple routine dot involving PermutationProduct that I wish to speed up using ...
6
votes
7answers
293 views

Sum of two functions, list processing

I am creating some simple graphs of functions defined by ordered pairs. Students are learning about "operations on functions", in this case, adding functions. If I have two functions defined by ...
6
votes
9answers
359 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 ...
6
votes
4answers
434 views

Convert head Times to List

I can convert an expression with the head of Times,for example, 12*12.5*13*13.5*14*14.5 to {12, 12.5, 13, 13.5, 14, 14.5} by ...
6
votes
5answers
244 views

Manipulating a sublist based on position

I have a huge list with huge sublists of the form list={{a,b,c,d},{e,f,g,h},{i,j,k,l}} I am looking for a way to manipulate these sublists based on the positions ...
6
votes
6answers
209 views

Sort a list of coordinates by frequency from first component of each coordinate

The situation is that I have a List like this: ...
6
votes
5answers
413 views

remove -1 values from a list

I would like to turn a list which looks like this one: {{-1, -1, -1}, {-1, 2, 3}, {-1, -1, 2}, {2, 3, 4}} into one which looks like that one: ...
6
votes
6answers
345 views

How can I merge two lists in a special way?

It's been over a year since I've used Mathematica, and I'm having a total brain fart on a home project. I'd like to take an existing list of lists, say, ...
6
votes
3answers
419 views

Sum over binary digits of integer

This might seem like a simple enough question but Mathematica seems to simplify inadequately here: How would you sum over the digits of an arbitrary binary number? I already tried this: ...
6
votes
5answers
246 views

Find positions of duplicates that are neighbours

Assuming the following list {1,2,3,3,5,6,3} I would like to get the position of values that are next to each other and are duplicates. That is, the output should be {3,4}. Thank you for any help. ...
6
votes
3answers
193 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... ...
6
votes
4answers
443 views

How to apply a function to a list of tuples

trialList = {{0, 24.701}, {1, 24.69}, {2, 24.733}}; f[x_] := x + 1; I would like to apply the function f to only the second ...
6
votes
3answers
215 views

Loop function over list [duplicate]

I would like to divide element 1 of a list by element 2; element 2 by element 3, and so on. What is the best way of doing this? I have tried f = #1/#2 & ...
6
votes
2answers
265 views

How can I find if the number of subsets for a list is very large?

I'm trying to find the following; Subsets[Range[2, 2300], {4}] but my computer gave the following error: ...
6
votes
5answers
363 views

Computing the equivalence classes of the symmetric transitive closure of a relation

I have a list of pairs, for example: ...
6
votes
4answers
258 views

Inserting points along a linear interval between adjacent coordinates in an array

Say I have a list of coordinates in an array {{0, 0}, {0, 1}, {1, 1}} I'd like to create a new array where, between each pair of nearest-neighbor coordinates in ...
6
votes
2answers
285 views

Map a function over the columns of an M x N array

I have a $N \times M$ list of lists, or rather, a list of records and I want to map a function over its columns (e.g. find the mean temperature, age, etc.). Map ...
6
votes
2answers
310 views

How to punch a hole in some 3D distribution of points

Suppose we have a long list of 3D Cartesian coordinates, defining a distribution of random points in 3D space. How could we remove all the points inside a sphere of radius ...
6
votes
3answers
293 views

Delete elements from a list really fast

I have this bit of code that works, but it's very slow when there are 600k elements in the list: ...
6
votes
3answers
464 views

Filtering elements from a list

Suppose that I have a list {{{2, 1}, {4, 3}, {2, 4}}, {{2, 1}, {4, 3}, {3, 1}}, {{2, 1}, {2, 4}, {3, 1}}, {{4, 3}, {2, 4}, {1, 2}}} I want to make a new list ...
6
votes
4answers
811 views

Alternatives to While Loops?

I am using Mathematica to run a probabilistic simulation. Essentially, I have a list of members of a population (they only have one, numerical, attribute, so it's just implemented as a list of ...
6
votes
3answers
340 views

How to take part (and then sum over) of specific level of an array?

Specifically, I want to take some elements of the lowest level of an array, and then sum over these elements while holding the higher level. Sorry for my vague expression, maybe an example would make ...
6
votes
3answers
832 views

Simulate MATLAB's meshgrid function

Here is MATLAB's meshgrid. I came up with these implementations in Mathematica: ...
6
votes
3answers
591 views

Generating a non-convex polyhedron from a list of vertex coordinates

I want to include a figure in a paper I am writing on Combinatorial Geometry which features a non-convex polyhedron given by the following vertices, EDIT: I was unaware that Mathematica could convert ...
6
votes
3answers
695 views

Ways to compute inner products of tensors

One way to evaluate the following sums is combining Table and Sum: $u_{abcd} = \sum_{e=1}^3 v_{aeb}w_{ced}$ $q_{ab} = \sum_{d,e=1}^3 v_{d e a}w_{deb}$ It will look like ...
6
votes
4answers
226 views

How to sum over duplicates?

I have a list of the form: {{1, 0, 1}, {2, 1, 2}, {1, 0, 3}, {2, 4, 2}, {2, 1, -1}, {1, 0 ,0}} that I would like to sort such that I calculate the sum over the ...
6
votes
3answers
630 views

print the name of the variable in a list without evaluation

a := az + 1 b := bz + 5 list := {a, b} I'd like mathematica to print a = az + 1 b = bz + 5 so basically it needs to first ...
6
votes
3answers
404 views

Replace “,” in a list with “.”

I have a list which consists of numbers which use comma (,) instead of dot (.) as their decimal point. I would like to replace the commas, but only those commas which are followed by more than five ...
6
votes
2answers
260 views

Merging two Lists

I have two tables. One is given by T1 = Table[{x, y, 0.}, {x, 0, V},{y, 0, V}] and from a calculation I have the second, a list of points {x, y, z} ...
6
votes
3answers
203 views

Importing and manipulating strings - time data

I have a list of time durations, which are strings of the form: "hh:mm:ss". Here's a sample for you to play with: ...