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

learn more… | top users | synonyms (3)

6
votes
3answers
703 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 ...
2
votes
2answers
292 views

Pattern test for variables during function definition

I am having a problem with pattern testing on variables during function definition ...
5
votes
1answer
123 views

RankedMax and Max do not behave identically

I have spent three hours debugging some code and at the end I think I found a bug. Otherwise I cannot explain what I am seeing: When I want to use RankedMax on ...
14
votes
4answers
575 views

Implementing a function which generalizes the merging step in merge sort

One of the key steps in merge sort is the merging step. Given two sorted lists sorted1={2,6,10,13,16,17,19}; sorted2={1,3,4,5,7,8,9,11,12,14,15,18,20}; of ...
35
votes
3answers
1k 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
281 views
16
votes
9answers
978 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
431 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
575 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
581 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
165 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
260 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
407 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
344 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
595 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
284 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
783 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
273 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
284 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
507 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
106 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
407 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
494 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
542 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
424 views

Add elements in a sublist

I have created a subset of arrays: ...
5
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 ...
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
276 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
552 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
611 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
359 views

Combining lists

How can I combine list1={{x1,y1},{x2,y2},{x3,y3}} and list2={{x4,y4},{x5,y5}} to ...
6
votes
2answers
436 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
129 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
229 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
304 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
402 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
436 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
490 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
766 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
527 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
363 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
430 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
603 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
501 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
761 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
678 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". ...