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

learn more… | top users | synonyms (3)

7
votes
4answers
248 views

Generate PrimePower counting function

Is there a way to generate a counting function for prime powers - i.e. to create a similar function to PrimePi, but including prime powers. The following will, of ...
1
vote
2answers
91 views

Delete duplicates from hierarchy of lists

Is it possible for Mathematica to compare a number of lists of different sizes, and delete duplicates in a hierarchical manner? For example, given the following lists: ...
1
vote
3answers
181 views

Generating a list of cubefree numbers

I am trying to generate a list of cubefree numbers (i.e. numbers when prime factorized contain no tripled factors) within a given range. Of DivisorSigma, ...
3
votes
1answer
69 views

Why does Thread FileDate give an error message?

I tried for example Thread[FileDate[FileNames["new*", "h:\\temp\\", 1]]] It gives FileDate::fstr: File specification ...
2
votes
2answers
173 views

Iteration problem

I am trying to write a simple program - perform f1 as long as t is smaller than 800. t is ...
17
votes
5answers
408 views

How to split list into disjoint lists?

I wonder if there is any simple way to split a list into its disjoint sublists, e.g. from list={{a,b},{e,f},{b,c},{c,d},{f,g,h}} get a result ...
0
votes
0answers
40 views

is there a way to speed up rule replace? [duplicate]

I am currently doing calculation with 7 parameters, each parameter set corresponding to a value. And I store the data in the format as a list of rule, like following ...
2
votes
2answers
240 views

Covariance of a P x M x N matrix

I have a stack of tiff files. When imported to Mathematica, they form a $P \times M \times N$ matrix, where $P$ is the number of single images in the stack, $M$ is the number of horizontal pixels and ...
0
votes
4answers
91 views

Seek a quick way to bring standard order back to original after Complement [duplicate]

the Complement gives result in standard order. But that's not what I want. I want it to keep the original order. say I have a list ...
0
votes
1answer
186 views

Passing lists to functions in a manner that works like pass-by-reference in other languages?

Is it possible to use a list as a variable, i.e., to pass it by reference to a function? In particular, I have a two-dimensional array and a function to get one element specified by its position: ...
5
votes
7answers
337 views

How to find the longest matching sublists in a list

Given a list of 2D points, i.e. {p1, p2, ..., pn} the list may contain equal points, i.e. pi = pj. In this case it may also be true that a sublist of ...
3
votes
1answer
104 views

Timing Total crashes kernel

Here is a simple test function test[n_] := Module[{i = 0}, Total[Nest[{++i, #}&, {0}, n], -1]] On my system V9.0.1 running OS X 10.6.8 and with a clean ...
1
vote
3answers
256 views

ListPlot multiple datasets over same x-values

Is there a better way to enter my data into a list plot? ...
5
votes
4answers
217 views

How to split a list with respect to its nested sublists?

I have a problem with the following task: having some nested list list = {{k6},{k1,k3,k5},{k7}} I would like to replace all sublists by their permutations and ...
2
votes
6answers
200 views

Manipulating List

I have a list: b={{1, 1}, {2, 2}, {3, 3}, {5, 5}, {6, 6}, {8, 8}, {10, 10}} I want to insert the elements in this list: ...
1
vote
0answers
67 views

The number of real values assumed by combinations of complex roots of a decic

Define complex conjugate as the pair of complex numbers $a+bi,a-bi$. Assume you have 5 such pairs and they are the 10 roots $x_i$ of a 10th-deg equation with integer coefficients. In general, how many ...
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 ...
13
votes
5answers
311 views

Partitioning a list of numbers the Mathematica way

I have two sorted lists, one list will be called the "fences" and the other the "values" Fences could be: $\{1, 5, 9, 14\}$ Values could be $\{-1, 1, 3, 4, 6, 9, 10, 13, 14, 15\}$ I want to ...
1
vote
4answers
140 views

Add Brackets to a string list

Hello stackexchange community! I have a stringlist with a value and his error for eg: {{"12","1"},{"13","2"}} Now i want to output this as something like this ...
3
votes
4answers
157 views

Pattern matching in nested lists

I'm sure this has been asked before, but I can't find the right combination of search keywords to find it. Apologies. I want to do a ReplaceAll on a list of lists, ...
3
votes
2answers
93 views

How to partition a list according to a nested table structure?

This question is related to this quesion. The goal is to use ParallelMap to map a function to a nested Table to get the ...
-1
votes
1answer
92 views

Efficient Table Generation & NDSolve Error

I'm currently working on solving an SEIR model with data from the CDC. I've created a function to calculate the Square difference for the model and want to create a table of values for the 4 variable ...
3
votes
3answers
128 views

Lists - pairing up

I have two (fairly large) lists of equal length & would like to pair them up. eg - from: a = {{0, 1}, {0, 2}, {0, 3}}; b = {{1, 2}, {1, 3}, {1, 4}}; I would ...
1
vote
3answers
166 views

Matlab-style Find in Mathematica? Value list and Boolean List, how to select values according to the boolean list?

I want to select elements with the true value (Indices list) in the corresponding point to the value list (MCS). Is there anything like Matlab-style Find to get the indices of true values in the ...
1
vote
3answers
93 views

ArrayRules for a ragged list

Let there be a sample list as , l = {a, {{b, c}}, {d, e}, {f}, {{g, {y}, u, h}, {{{{k, j}}}}},k, {{{{q}, {w}, {r}, {x}}}}}; ArrayRules[l] ArrayRules::rect: ...
2
votes
1answer
77 views

Putting values into a grid after iteration process

I'm developing a model of thermodynamic cycle in Mathematica. I wrote several functions, applied them to a list containing starting values and iterated, for the model to converge. ...
6
votes
5answers
226 views

Removing reverse versions of lists from a nested list [duplicate]

I need to remove the reverse versions of lists from list of lists. I.e.: {{1,2},{2,2},{2,1},{a,1,2},{2,1,a}} I need to reduce to ...
12
votes
4answers
336 views

Equivalent Nested Loop Structure

Consider the following examples: ...
3
votes
2answers
111 views

Change all values of a series to positive values

I would like to change all values of a series to positive values. I refer to my previous question, answered in the most part, very elegantly by RunnyKine. However, there remains a slight glitch that ...
3
votes
3answers
92 views

Filling in explicit zeros in a (x,y) list for nonexisting y values for discrete Fourier transform in Mathematica

I have a list of (x,y) values in Mathematica for various discrete x values, as in ...
4
votes
1answer
150 views

List manipulation - various

Update OK, Please forgive the messiness of this, but I am working with something like: ...
0
votes
0answers
26 views

Eliminate some value from a matrix [duplicate]

I have a function that return a table consisting of a 2D points. These points are either {x,y} or {0,0} ...
2
votes
4answers
134 views

Looking for mismatches between two lists

I'm able to do what I need, but it seems like there's always a better way. I have two lists, epiExcel and epiDB. Each has 3 columns and about 2,500 rows. I need to find out if the first 2 columns ...
1
vote
1answer
79 views

Replacement variable in list plot

I would like the replacement: /. {ComplexInfinity -> 0} to be treated as a variable. I am trying to overlay the following list plots: ...
8
votes
1answer
230 views

Two ways of map a function on the list: Which one is faster?

There are 2 ways to make a function listable on the list: Use Map or use SetAttributes. My question is, which one is faster, ...
2
votes
2answers
123 views

How to delete all rows in datafile that contain a string

I'm importing some data from a file. However, the file was created by an unreliable instrument, such that the data looks like this: ...
3
votes
3answers
86 views

How to get different items in a list to interact to get a result?

I have two lists, for example (the real lists are much longer): list1 = {1, 2, 3, 4, 5, 6, 7}; list2 = {9, 10, 11, 12, 13, 14, 15}; I want to create a single ...
5
votes
3answers
139 views

Preserving a bijection between arrays when shuffling elements in one array

Imagine I have two lists of elements like the following: listOne = RandomReal[{0,2}, {100,2}]; listTwo = RandomReal[{0,2}, {100,2}]; Let $f: X \to Y$ be a ...
3
votes
2answers
162 views

Provided an array of 2D point clouds, can we quickly replace distance- and index-based cliques of points with their median or mean values?

Imagine I have $N \approx 10^5$ clouds of points in an array of the form: UPDATED ...
11
votes
9answers
493 views

How to partition a list of numbers in two lists of numbers such that each lists elements sums up to the same number?

I have the following list of squares. {1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256} Their sum is $1496$, I want to make two partitions ...
0
votes
1answer
35 views

Pruning coordinates in subarrays of a list conditional on them having non-real components

If I have a list of 2D coordinates placed in subarrays of a data structure like the following: ...
1
vote
2answers
209 views

Swapping elements of list

Say I have a directed graph inputted in the following format in Mathematica: g = {{1, "a", 2}, {2, "b", 1}} I'd like to plot this graph using ...
1
vote
3answers
104 views

Quickly pruning elements in one structured array that exist in a separate unordered array

I have two lists, which we'll call testList and modifiedTestList. The first list looks something like this: ...
3
votes
2answers
161 views

Variable length list with # and [[i]] as elements

I need to create a list that as an input receives the number $N$ of elements that it will contain and that returns: ...
1
vote
1answer
83 views

Reading between blank lines in external data files

I have an external data file with several columns and thousands lines of data. For the sake of this question, let's assume that we use ...
4
votes
4answers
209 views

Can I generate a “piecewise” list from a list in a fast and elegant way?

Suppose we have a number list a: n = 1000000; a = RandomReal[{0, 1}, {n}]; We want to generate a list ...
5
votes
4answers
266 views

Removing empty sets from lists

If I had a list, say, names= {"Andy", "Bob", "Carly", "Sandy", "Jeff", "Tim", "Tom", "Zach"} and I decide to pick a characteristic only a certain of them have, ...
0
votes
1answer
94 views

How do you find the longest sublist within a nested list

Say, I have a list stuff={{eat,tea,now},{how,did,you,say},{the,cat,ate,was,can},{win,din,sin}} I have a nested list and I want to find the list that has the most ...
3
votes
1answer
247 views

Plotting multiple lists of complex numbers

The user #Nasser showed an elegant way to plot complex numbers: ...
4
votes
0answers
139 views

Visualizing nested lists for easier human understanding

When interacting with Mathematica, I often find myself staring blankly at waves of curly braces, trying to understand how data is organized hierarchically. For example, the beginning of the result to ...