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

learn more… | top users | synonyms (3)

1
vote
2answers
64 views

Replacing a specific pattern of values at level 2 in a list

I've a list of lists, tl = {{True, False, m12}, {False, m22, m33}, {m32, False, True}} and each nested list has the same length, What is the proper way to ...
3
votes
3answers
93 views

How to test if all the elements in a list are Integers? [closed]

Consider a list such as s={1,2,3,3,5,6,3} With IntegerQ[number] , you know if number is an ...
3
votes
2answers
214 views

Dealing with a huge dataset

I have two ingredients here: a big dataset contained in a list, with ~ 20M values. a function that takes as each element of the list as input and yields True or False I want to save somewhere the ...
2
votes
3answers
108 views

Delete Missing data from coordinate sets

I have a list of pairs of coordinates, where some are missing. ...
2
votes
2answers
127 views

Permuting elements within a list

I have s = {2, 3, 5, 7, 1, 4, 6} (* always with diffente elements in {1,2....7}*) l = Length[s] n = 3 and n tells us that we ...
0
votes
1answer
43 views

Resolving Error: Mathematica evaluation order on Lists

I have a table that is 27 x 27, each entry corresponds to an element from the periodic table. I use the replacement rules in element list to allow me to convert a list of elements into a list of ...
2
votes
2answers
87 views

Importing Data and Devoting Their Names to Them

There are some files in a directory. I have used of SetDiroctory to access all of them. SetDirectory["C:\\Users\\SE7EN\\Desktop\\mathematica\\test"]; I can visit ...
8
votes
4answers
278 views

Complement of multisets

Given lists $a$ and $b$, which represent multisets, how can I compute the complement $a\setminus b$? I'd like to construct a function xunion that returns the ...
2
votes
1answer
44 views

Complement for a Matrix

In a matrix, there are some non-zero elements same as: aA= Also, there is a list such as: list = {a, b, c, d, e, f, g, ii, jj, kk}; I want to access to ...
3
votes
2answers
177 views

make a list based on two other lists

I have two lists: list1={4,6} list2={1,2} and I now want a function f that produces f[list1_,list2_]:={1,1,1,1,2,2,2,2,2,2} ...
1
vote
0answers
35 views

A more efficient way of fitting a non-linear model that returns an entire list?

I have a function that takes two parameters, del and nu, and returns a list npoints long ...
4
votes
3answers
375 views

Efficient matrix / array generation

What is the most efficient way of generating the following matrix? $\left( \begin{array}{ccccc} 1 & 0 & 1 & 0 & 1 & 0 & 1 & \dots\\ \frac{1}{2} & \frac{1}{2} & 0 ...
0
votes
1answer
71 views

how to apply a function to a list of tables

I have several files, and I want to extract for each of them a table, and then select just numbers, and keep only rows with five elements. My code works fine during import ...
2
votes
2answers
90 views

select from a list based on digits

I wish to know how do I count the number of occurrences of numbers that end in digits d. e.g. Say I create a list of Divisors of 12! I now want to count those divisors that end in 12. Like 12 & ...
0
votes
0answers
77 views

mdifying a code for nested matrices

I have a matrix such as: ...
0
votes
2answers
84 views

How do I perform the riffle function backward? [duplicate]

I know riffle will combine the lists {1,2,3} and {a,b,c} to be {1,a,2,b,3,c}. Is there a way to work backward and split the list {a,b,c,d,e,f} to be {a,c,e} and {b,d,f}?
8
votes
2answers
348 views

Aligning two lists

I have two lists, L1 and L2, each with a key and some data. Let us say the key is a person's name, a string, and the data follows. (To respond to rasher's query:) Let us also assume the lists are ...
1
vote
2answers
133 views

position of element in a list using a function

How can I find in a list l the positions of all elements satisfying a boolean function f. For example, how can I pick in ...
3
votes
6answers
313 views

How can I construct a distance table?

I have a list of city names (of arbitrary length), f.e. c = {"BAL", "NYC", "LAS", "AUS"}; and the distances between them : ...
1
vote
2answers
145 views

Find equal elements on a list

Consider the following code to produce the sequence $x_1,\ldots,x_{n+1}$ where $x_i=11\cdots1$ ($i$ digits 1). Is there an easier way to do this? ...
2
votes
1answer
91 views
0
votes
1answer
54 views

Taking Mean for several elements of a list [duplicate]

i have the following question: Let us assume we have the following list: list={1.1,1.2,1.0,2.1,2.2,2,0,3.1,3.0,3.2} I need a function that always takes three ...
1
vote
3answers
119 views

Working with nested matrices

I have a matrix: A = {{a, b}, {c, d}} But each its element, itself, is another matrix too. ...
0
votes
1answer
146 views

How to load data into a Manipulate expression

I have data showing truncated octahedron geometry changing with time. How can I read those data into a Manipulate expression? To be specific, I want to manipulate ...
0
votes
1answer
40 views

Testing a certain function over multiple levels

I regularly want to test if a certain function, here foo, gives the expected result when mapping it over n - level - matrices. My naive approach is to write: ...
0
votes
1answer
62 views

Swapping rows and columns in matrix [closed]

If I have an array like the following $\left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{array} \right)$ How can I swap the rows and columns, so it is ...
0
votes
2answers
149 views

How to pass a list as function argument?

I have the following function lFreqPhylo[a_, Q_, b_, p_] := Sum[Log[freqFunction[r[[p]][[i]], L[[p]][[i]], a, Q, b, {i, 1, nbranches[[p]]}]; The objects L, r ...
0
votes
0answers
27 views

Unexpected results from Thread [duplicate]

I've run into an issue where threading two lists with a generic function, f: Thread[f[{{1,1}, {2, 2}, {3, 3}}, {4, 5, 6}]] ...
2
votes
1answer
173 views

Is there a better way to create my rotational-symmetric (180 degrees) rectangles?

I have created a simple way to create rotational-symmetric (180 degrees) rectangles, but my stuffit function bothers me. No matter what I tried, I couldn't get it ...
0
votes
1answer
71 views

Help with DeleteCases [closed]

Trying to delete small elements from a list with copy = DeleteCases[copy, {y_} /; y <= 1500.0 ] but it does not work.
0
votes
1answer
66 views

Apply function to output of previous function

I am trying to write a function that takes 3 tuples. Each tuple contains two lists which are first divided. This results in 3 lists. Then I want to take the Mean of all the columns. I can do this ...
1
vote
1answer
75 views

Matrix and string variable

There are $100$ .dat data files which contain numerical parameters. ...
1
vote
1answer
59 views

If statement and elements of an imported data

I import a data file: SetDirectory["C:\\Users\\SE7EN\\Desktop\\mathematica\\test"]; dd = Import["data.dat", "Table"] Out[2] = {{1}, {2}, {3}, {4}, {5}, {6}, {7}} ...
0
votes
1answer
53 views

Manipulating lists with constant values [duplicate]

let us assume we have some data in the following form. Table[data[[1,i,{1,2}]],{i,1,Length[data[[1]]]}] This would give all $x-y$ pairs of the first file. What I ...
1
vote
1answer
73 views

How to find the maximum values and the place of the max value in the list? [duplicate]

I have given an example to find the maximum value and its place in the list. Is it possible to find the local maximum in the sub-list of this list means local maximum in the each row of the list and ...
3
votes
0answers
78 views

Why does Part behave like it transposes lists? [closed]

From the documentation of Part: Part[expr,i,j,...] is equivalent to expr[[i]][[j]]... ...
3
votes
2answers
102 views

Converting unevaluated lists to strings

I have a list like l = {2 - 3, 12 - 4, Times, aab} I want to end up with {"2-3", "12-4", "Times", "aab"} I have tried ...
8
votes
1answer
112 views

Strange behavior of BinCounts

Just try this example: ...
2
votes
2answers
122 views

Building adjacency matrix from set data

I have two sets: games and players. Players pick their games. As such I will have data say g1={p1,p3,p5},g2={p2,p4},g3={p2,p3,p5}. My interest though is to build the connections among players because ...
4
votes
1answer
135 views

Selectively converting numerical strings to expressions

I have a list of strings representing different types of data ...
1
vote
1answer
47 views

Grouping Nested Lists Based on Differing Values of Single Element

I've a list of lists representing k-rows of truth table having n elements each in a nested list consider ...
0
votes
1answer
45 views

Generating list of functions from list of expressions

I know how to create a function from concrete expression like Function[{x, y}, x^2 + y^2] But what if I have a list of expressions list1 and I know the set of ...
1
vote
2answers
73 views

Manipulate which creates and deletes Manipulators dynamically

I want to plot a function in a Manipulate in which the number of terms varies and a Manipulator for the coefficient of each term ...
0
votes
1answer
86 views

Select positive value from a vector

I am wondering how to pick out the positive Omega value from soln, and make these positive values into a row vector. I know how ...
0
votes
1answer
64 views

How to discriminate Weatherdata latitude and longitude from a more detailed list

From this list of weather data how can I discriminate only latitude longitude for each station? For example from the following sample I would need only the coordinates: "50136","","Aoluguya|Mohe, ...
1
vote
2answers
103 views

How to drop the identical rows and columns of a matrix?

I'm currently trying to find a way to eliminate from a square matrix of generic dimension the duplicate (up to sign) rows and columns, obtaining a smaller dimensional matrix. I searched around here ...
0
votes
1answer
92 views

How do you add options to a function that is being mapped?

Simple example: Normally: ListPlot[list, Joined->True] If I want to map ListPlot how do I keep the ...
1
vote
2answers
122 views

From a list of (x,y) pairs, generate a new list of (x,ymean) pairs, where ymean is the average of all y's with the same x in the original list [duplicate]

This seems like the sort of thing where Mathematica can give a very simple solution. I have a list of points {x,y}: ...
0
votes
2answers
73 views

Merging two lists by prepending elements

Being a newcomer to Mathematica, I have the following question. Given x = Range@9~Partition~3; and y = {a, b, c}; I want ...
1
vote
1answer
70 views

How can I get a certain kind of iteration? [closed]

Can I get this type of do-loop in Mathematica? Do[Print[j," ",k," ",l], {j,k,l, {a, b,z}, { c, d,y} }] I want this to work so that, in the first iteration, ...