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

learn more… | top users | synonyms (3)

8
votes
2answers
350 views

Retrieving duplicates from nested list

Consider the following: data={{1,a},{10,a},{5,b},{4,c}}; In my case duplicates are defined when for {x1,y1} and ...
26
votes
4answers
605 views

How to make MapAt work with Span?

Span (;;) is very useful, but doesn't work with a lot of functions. Given the following input ...
9
votes
4answers
294 views

MapThread with non-rectangular lists

MapThread works fine and dandy with rectangular list structures: MapThread[f, {{{a, b}, {c, d}}, {{1, 2}, {3, 4}}}, 2] ...
8
votes
2answers
812 views

Rapidly binning 3D data

I have a set of data (about 20 million datapoints for my real data) of the form {x, y, z, m}. There are 3 spatial coordinates x, ...
10
votes
2answers
285 views

Using Gather to rearrange my data

I have a list of elements: {{1, 2}, {1, 5}, {2, 6}, {3, 7}, {4, 8}, {5, 6}, {5, 9}, {9, 13}, {10,11}, {11, 12}, {11, 15}, {15, 16}} I have to divide it into ...
4
votes
4answers
299 views

Add/replace a rule in a list of rules based upon the rule's lhs without regard for the rule's rhs

I have the following lists of rules: {x -> 1, y -> 2} {x -> 1, y -> 2, z -> 4} {x -> 1, y -> 2, z -> 2} For each list of rules, I would ...
11
votes
3answers
522 views

Delete duplicates in a list, depending on the sequence of numbers

Below, list is a representative sample of my list, which contains lists of integers. I would like to be able to input: ...
2
votes
2answers
107 views

Using FreeQ with implicit functions

In Mathematica 7, I want to determine whether a list of free of numbers greater than 1 or not. It seems like using FreeQ would be a concise way to do this: ...
5
votes
4answers
412 views

Leveling peaks in list

Consider the following: data={2,2,2,5,3,3,3,6,1,1,1,0}; In[1]:=result=MyFunction@data Out[1]:={2,2,3.5,3.5,3,3,4.5,4.5,1,1,1,0} ...
14
votes
3answers
508 views

Determining all possible traversals of a tree

I have a list: B={423, {{53, {39, 65, 423}}, {66, {67, 81, 423}}, {424, {25, 40, 423}}}}; This list can be visualized as a tree using ...
21
votes
11answers
547 views

Using MapAt to map at a particular depth (levelspec)

I have the following sample list (my actual list is, of course, much longer): ...
5
votes
2answers
450 views

Add elements in a sublist

I have created a subset of arrays: ...
6
votes
2answers
2k views

Is it possible to compute trapezoidal rule numerical integration?

Is it possible to compute trapezoidal rule numerical integration? I know that Mathematica has Interpolation, and that a list of points can be interpolated and then ...
22
votes
2answers
1k views

Populating and storing a very large array in Mathematica

I am using Mathematica 8 to generate a very large multidimensional array of floating-point numbers and then store it in a file. Typical array sizes are 10000 x 50 x 15 x 40, resulting in a 3-4 GB ...
7
votes
4answers
291 views

Evaluating a function using arguments from a sliding window over a list [duplicate]

Possible Duplicate: How to Map a subset of list elements to a function? I want to evaluate a function using arguments from a sliding window over a list. As an example, lets use ...
10
votes
4answers
2k views

What is the cleanest way to prevent divide-by-zero warnings?

If I evaluate {1, 2, 3, 4}/{5, 6, 0, 8}, obviously I get one warning: ...
7
votes
4answers
563 views

Filter a list generated with Tuples

I generated with Tuples[{{1, 2, 3, 4, 5}, {1, 2, 3, 4, 14}, {1, 2, 3, 4}, {1, 2, 3, 4}, {1, 5, 6, 7, 8}, {5, 6, 7, 8, 10}, {5, 6, 7, 8}, {5, 6, 7, 8}}] ...
5
votes
3answers
246 views

Point belonging to a Disk in a Cartesian Coordinate System

The image below represents a human subject fixations while observing this abstract pattern for 3 seconds. I would like to know how much time they spent looking at the actual disk. That is a red point ...
6
votes
3answers
637 views

Subsets of a list

Consider the following demand of products for the next four months. data={1,20,3,40}; I could produce the whole demand in the first months, leading to the ...
-1
votes
3answers
366 views

Combining lists

How can I combine list1={{x1,y1},{x2,y2},{x3,y3}} and list2={{x4,y4},{x5,y5}} to ...
6
votes
2answers
463 views

Splitting a list at a particular position

Is it possible to split a list into two lists at a specific position? The main list is for example: data={{xa,ya},{xb,yb},{xc,yc},...,{xz,yz}}. I want to split ...
1
vote
3answers
135 views

How can parts of a list of lists be printed to the nb, at regular interval positions?

I have a large list of lists with the dimensions {441,21,21,3} of which I need to print the x,y,z data from every 21st part up to 441. How can I print the 21x21x3 piece of every 21st part of this ...
0
votes
2answers
233 views

Recursion on a moving window

I need to apply some computations to a moving window of $N$ items in a time series and I am struggling with doing recursion and shifting the considered window. To illustrate, please consider the ...
4
votes
3answers
307 views

Counting elements skipped using Reap & Sow

I am using the following code to filter data based on the percentage change between points. ...
6
votes
1answer
424 views

Finding all length-n words on an alphabet that have a specified number of each letter

For example, I might want to generate all length n=6 words on the alphabet {A, B, C} that have one ...
21
votes
3answers
450 views

Is there a bug in Pick?

I wanted to use the Pick function with a condition. But there seems to be an issue here. Take a look at this: ...
9
votes
8answers
506 views

Adding elements to a collection of lists

I would like to add element a at the start of a series of lists. For example I have a collection of lists called ...
6
votes
3answers
840 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 ...
13
votes
5answers
535 views

Interlacing a single number into a long list

This seems like it should be a simple question, but I am running into some difficulty in doing this with Mathematica. Right now, I have a list like this: ...
6
votes
1answer
390 views

ReplaceAll inside an Iterator

I'd like to apply a set of rules to an expression defining the iterators of the table, like this: ...
18
votes
3answers
437 views

Is there a faster way to create a matrix of indices from ragged data?

I have data that is given as a list of ordered pairs mixed with scalars. The pairs can contain infinite bounds. My goal is to convert the data into an index used in future computations. ...
2
votes
3answers
621 views

Problem with Union and Intersection

Consider the following: list={{a,b,c},{c,d,e},{d,e,f},...{x_,y_,z_}}; I would like to apply Union on the elements of the list ...
14
votes
2answers
514 views

Reproducing nested loops using Map?

I keep producing bits of code like the following: ...
5
votes
4answers
2k views

Append in For loop does not work

I need to break my for loop in case of an thrown message and append s to the result list. Breaking the loop works, but my result is empty. I can not use Table[] ...
3
votes
3answers
860 views

How to replace all occurrences of an element in a list?

Consider the following: list={1,2,2,2,3}; I would like to replace all 2 with the string "Test". ...
8
votes
5answers
2k views

How to create a list of pairs from 1d list(s)?

Say I've got two 1-dimensional lists A = {1,2,3} B = {a,b,c} How do I create a list of all pairs from list A such that the ...
12
votes
7answers
705 views

DeleteCases on list of Strings

Consider the following: data={"AB","CD","AF"}; Now I would like to delete all String from data which starts with "A". ...
2
votes
1answer
345 views

Symmetric difference of a sample of lists

Consider the following: list1={a,b,c,d}; list2={c,d,e,f}; list3={g,d,c,h}; Now I would like to get the symmetric difference. Hence, the result must be ...
5
votes
1answer
534 views

Computing the distance between two curves obtained from image data?

I've got some image data that I've binarized. The image contains two curves, from which I'd like to compute the distance between (eventually computing an average radius for each point in the ...
6
votes
2answers
221 views

Threading behavior of SameQ vs Equals

I ran into a bug in my code today based on an errant assumption. Namely, I thought that: ...
2
votes
1answer
446 views

Adding rules to permutations

How can I calculate only those permutations of Range[n], that satisfy certain rules? I don't want to filter the result after calculating all the permutations but ...
2
votes
1answer
179 views

List-operations only when restrictions are fulfilled (Part 2)

Consider the following: data={{{3544128000, 80}, {3544732800, 80}, {3545337600, 80}, {3545942400, 80}, {3545942400, 160}, {3546547200, 160}, {3547152000, 0}}}; ...
12
votes
7answers
507 views
2
votes
2answers
130 views

A question about transforming one List into two Lists with additional requirements

Background: I create geometric patterns by applying many linear transformations on geometries, I need functions to weed out the exponentially increasing number of ( unnecessary ) points involved which ...
9
votes
3answers
249 views

Splitting a list in which figures vary from negative to positive

Consider the following list: data={4078, 256, -1266, -388, 1290, 1368, 1446, 1524, 2}; I would like to split any kind of such list always, when figures turn form ...
14
votes
5answers
836 views

Picking random items out of a list only once

I'm trying to create a function that randomly returns a value from a list but remembers the values that have been given before. At the end when the list is empty it should return an empty list. ...
7
votes
3answers
537 views

Add lists with unequal lengths together to create a matrix

I'm trying to create a stacked bar chart using raw data coming from a MySQL server. The result coming back from one query is: ...
10
votes
6answers
601 views

How to Map a subset of list elements to a function?

How would you, given a list {1, 2, 3, 4}, apply a function f to 1 and ...
12
votes
2answers
456 views

Are there advantages to using generalized Part extraction instead of specialized functions like First, Last?

There are many ways to extract different parts of lists in Mathematica. For example, the first part of a list v can be accessed either as ...
10
votes
8answers
2k views

Map and Apply a function on a nested list

I have a list like this: {{1,2}, {4,2}, {6,4} ... } I want to replace every second number with a function of that number. For e.g. ...