Tagged Questions

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

173 views

Finding largest Range in a list

In a list of positive integers, I would like to find the largest n such that Range[n] is a subset of the list. So for example ...
490 views

I was hoping to find an elegant solution to this riddle, using only a line or two of Mathematica: Santa Claus was telling one of his elves: "If I multiply the age of three of my reindeer, I get ...
166 views

GatherBy based on condition imposed on index variable

Excuse me. This might be user specific question but I need your help. I have an indexed data, where positive integers are used for indexing data. I am trying to group data putting condition on index ...
426 views

TemporalData, RandomFunction, Loops: Extracting data from TemporalData sets?

I'm doing a finance project for my differential equations class to explore stochastic processes. I'm exploring IRA retirement funds. From the project write-up: Standing assumption: at time of ...
115 views

Why is Nearest not giving me expected result

I have the following list: numbers={0.,0.6,0.8,1.,1.2,1.4,1.8} Then I calculate the midpoints: ...
46 views

Regarding Cycles and Lists of Functions

So, I'm trying to determine the Normal Matrix of a Least Squares Aproximation; I have a basis constituted by 8 functions f1,f2...f8; I have 9 points which constitute Datax = {x1,x2...x9} Now, I ...
124 views

for loop and list

I'm new to Mathematica. I want to built a function like that; ...
119 views

Request for Explanation in case of Replacement not working

The 2 code snippets work on a matrix ABg with 22 rows and two columns containing Strings. Some entries in column 2 are List { } to be recognized by the first Character "{". In the list some items must ...
135 views

Find maximum number of instances with FindInstance[]

I understand that ...
102 views

While subpartitioning the elements in list using GatherBy, can I corresponding subpartition the elements of an unrelated list?

If we have a list like the following: list1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; And we use GatherBy to subpartition is according to a test function <...
57 views

Subpartitioning elements of a list based on some h[ri] == h[rj] test

If we have a list of elements: list = {r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12}; I'd like to further partition the elements into sets where, for some ...
67 views

Efficiently testing if every member of a sublist comes before every other member of another sublist

I have a list of elements - ...
841 views

How to add an extra column to a current matrix (list)? [duplicate]

a = {{-800, 1712}, {-801, 1713}, {-806, 1832}} TableForm[a] b = a[[All, 2]] - Min[a[[All, 2]]] How do I make a new matrix (list) whic looks like this ...
63 views

Creating a list of triangle-square numbers up to n_

I have to, for a class, create a function that gives you the triangular-square numbers up to n. That said, here's the code I have: ...
226 views

how can one select elements from a list that are satisfied a criteria which need to compare with other elements in the list?

For example: I want to select elements from a list {1,4,3,2,5} that are bigger than its previous element. {4,5} satisfies the criteria: 4 is greater than 1 and 5 is greater than 2(Ignore the first ...
124 views

Use a categorical argument to add one layer of list structure

Consider the following nested list x = {{1,2,a}, {3,4,a}, {8,11,b}, {12,3,a}, {4,3,b}, {3,2,c}} I want to use the categorical variable ...
94 views

Insert at specific resulting positions in multidimensional list?

I have an initial "multidimensional" list (that is, a list that is not a vector): list0 = {{1},{2,3,4},{3,4},{5}}; and I want to insert elements ...
89 views

Insert at specific resulting positions?

I have an initial list: list0 = {1,2,3,4,5}; and I want to insert {a,x} at specific positions ...
109 views

Plotting data from specific column

I have data like this: 1406998993.147 73 TCP_MISS/200 22284, 1406998993.158 109 TCP_MISS/200 83827, 1406998993.197 111 TCP_MISS/200 57020, If I want to plot the column 1 and ...
123 views

Constructing new lists using Table

I tried to modify an old notebook to show a spreadsheet style output in a table. I am not getting any errors when it runs, so I think the data I am gathering and the new variables I added, ...
71 views

Deleting list elements at a certain level

I have a large list of 3 by 3 matrices such that the dimensions of the list for an example 100 matrices would be: {100,3,3} I have written a function that locates all the matrices I do not want and ...
169 views

Table operation after export and import of data does not give me the same result

If I create a table of this kind: (m1 = Table[{RandomInteger[], RandomInteger[{1, 5}, {3}]}, {i, 1, 5}]) // MatrixForm which looks like I know how to pick ...
99 views

Simple arithmetic operations on elements of a list [duplicate]

How can I shift the first element of a list by 148.38 and the second element by -38.45? The data ...
92 views

second part of a list with something like BinLists

I have a list that looks like this testList = Transpose@Table[{RandomInteger[{0, 100}], RandomReal[]}, {100}]; i.e. basically two lists in one. Using BinLists ...
303 views

How to remove hours, minutes, seconds from list

How to remove 0 that represent hours, minutes, and seconds from a date list say a ...
69 views

In each sublist, replace the value in the right part by the value in the left part

Consider the following nested list {{a,1/x},{b,2x},{c,Sqrt[x]},{d,1-1/x}} I'd like to come up with the same list where the variable $x$ is systematically ...
150 views

New nested list from three lists

I have three lists. x = {a,b,c,d} y = {A,B,C} z = {{1,2,3},{4,5,6},{7,8,9},{10,11,12}} and I wish to construct the following list out of these three lists ...
131 views

Why doesn't Thread work in this case?

The following function is supposed to pick the element of the list with highest weight, i.e., with Thread [f[{{a,1},{b,2}}]] it should make the variables ...
147 views

How to pick the maximum of a list? Improving efficiency

I need to find the element of a list, with the highest weight. Example: ...
91 views

List Manipulation and Removing Cases

I've imported a large data set, manually removing headers in the .rtf file where it originates. However, when I import this data, I receive this output: ...
244 views

Trouble with Position[] [duplicate]

I am in trouble with Position, Although my example works as expected it throws a warning. Position[{{a,b},{a,c},{a,b}}, _?(#[[2]]==b&), {1}] During ...
83 views

How to use Hold on a variable defined as a graph

I'm working on doing operations on different graphs and getting their probability node degree distributions using a simple algorithm. If I have many defined graphs, for example: ...
87 views

How to make a table of successive values

I want a list, where each entry is of the form {x,y}. I want x to go from $-\pi / 2$ all the way up to $\pi/2$. I also want <...
70 views

Elegant ways of solving this file batching task

There are a batch of data files in a folder (dir = "D:\\Documents\\datadir"), each of which consists of a list of data items, one per line. Each data item is a pair ...
375 views

Partition list into a given number of sub-lists

I'm having quite a hard time with the following. I would like to partition a list into a list of sub-lists, in such a way that the number n of sub-lists is fixed. ...
114 views

Comparing two lists lexically

I have two lists of integers a and b of equal length, and I would like to define a>b as ...
66 views

Create a matrix by crossing a list

I've a list L of elements. I want to create a matrix by laying each elements of L in both rows and columns where each ...
70 views

NSolve gives {{ x -> #}}, How do I make x = #; I need to use the x value again later

I want to use: demand = {1.92, 2.07, 2.37, 2.72, 2.87}*10^6; NSolve[SetV == demand[[1]]/(Cpf (1 - χ)), χ] I want to make a vector of solutions ...
142 views

How can I use parts of lists with Dynamic?

I'm a newbie - what am I doing wrong? I want to use parts of lists (vectors) in calculations but Mathematica will not evaluate anything that involves parts of lists that update dynamically. Is there a ...
329 views

What quantity is this “length” called?

tmp = {x, y, z}^{1, 2, 3} Times @@ tmp Length[%] This gives a length of 3. But I was expecting 1. What is exactly this "length" of x*y^2*z^3 called? I would ...
140 views

List Manipulation Via Conditionals

I'm trying to convert one list to another by applying a condition on the list's elements. But I can't figure out how to do this in mathematica's language. Python example below ...
181 views

Finding the index of (x,y) pairs in a list

I have a large list of $(x,y)$ pairs, and I want to find the index of a particular pair in order to extract some data from another array. By way of an example, ...
127 views

Why Delete does not work?

I'm trying random thing in Mathematica just for learning and I can't solve this problem. I want to use the Detele function to delete some elements in a list but it'...
96 views

Displaying a list in form of an upside down pyramid graphic

I was wondering how to display a list like this: list={{0,1,1,0},{1,0,1},{1,1},{0}} in form of an upside down pyramid, that is the first element of the list is ...
803 views

How to build this grid with less code?

I have the diagonal and both upper and lower triangulars of a grid. ...
76 views

Compilation of a function that needs to call Subsets

I'm working on a code that runs many (easy) operations on combinations (subsets) of different size (6, 7, 8, 9) taken from a big set of numbers (normally more that 40). So, this means the code has to ...
183 views

Mathematica List Selection

I have a list which contains these elements : ...
287 views

Merging two lists with possible different keys

This is very similar to my earlier question One to Many Lists Merge but somehow different. I have two lists, first column in each list represents its key. I want to merge these two lists. The only ...