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

learn more… | top users | synonyms (3)

35
votes
3answers
958 views

Tiling a square

I wondered if there was a way to automate the process of finding a way to tile a tile into a square. The idea is to represent the tile with a matrix of $0$s for blank space and $1$s for filled spaces ...
8
votes
2answers
268 views
16
votes
9answers
842 views

How do you check if there are any equal arguments(even sublist) in a list?

I would like to set up a function which has to return True if at least two arguments of a given List are equal. So if I give {1,4,6,2} to the function it has to ...
16
votes
4answers
408 views

Splitting a list

Please consider the following list: data={1, 0, 0, 0, 2, 5, 2, 3, 0, 0, 3}; Now I would like to split the list into 0-sequences and Not-0-sequences as following: ...
2
votes
1answer
436 views

Indices and variable definitions in Mathematica

Does anyone know how I can do this in Mathematica? Just an example.. Defining indices and variables (defined over indices), "mapping" variables and indices: ...
10
votes
3answers
509 views

Count consecutive positions with the same value

I want to program a function that counts the successive positions with the same value: In[]= ConsecutiveValues[{1, 1, 1, 1, 2, 2, 1, 0}] Out[]= {4, 2, 1, 1} In ...
7
votes
3answers
163 views

List has a date and amount, I need to create a cumulative amount by date

I have a list which has a date and a amount, I need to create a list that has the cummulative total with the date. I have the following result: ...
6
votes
2answers
251 views

How to choose variables from a list for a function and then use the solution in a subsequent function?

I am trying to calculate heating degree days and cooling degree days and output that information to a table. I am using mathematica's curated data to do this. In text this is what I would like to ...
6
votes
3answers
337 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 ...
8
votes
2answers
318 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 ...
23
votes
4answers
467 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
253 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
668 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
259 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
261 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
448 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
95 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
386 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} ...
13
votes
3answers
449 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 ...
18
votes
11answers
511 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
334 views

Add elements in a sublist

I have created a subset of arrays: ...
4
votes
2answers
1k 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 ...
20
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
239 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 ...
8
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
476 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
237 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
576 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
351 views

Combining lists

How can I combine list1={{x1,y1},{x2,y2},{x3,y3}} and list2={{x4,y4},{x5,y5}} to ...
6
votes
2answers
375 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
108 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
213 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
285 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
345 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
422 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
443 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
629 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
500 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
282 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
416 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
573 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 ...
12
votes
2answers
464 views

Reproducing nested loops using Map?

I keep producing bits of code like the following: ...
4
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
544 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
1k 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
557 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
295 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
468 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 ...
5
votes
2answers
186 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
402 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 ...