Questions tagged [list-manipulation]

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

Filter by
Sorted by
Tagged with
3
votes
1answer
38 views

Order or function/list arguments in map/select/others

I keep being uncertain of the correct order of [function,expr] arguments to functions such as Select, Pick, Cases, Position, etc., because I'm used to the ...
0
votes
0answers
27 views

List connected with another list [on hold]

list1 = Table[n^3, {n, 3}] list2 = [list1, Table[Pi*n, {n, 3}], Table[3 n, {n, 3}]] So i have these commands list1 is correct it shows me excactly what i want but ...
2
votes
1answer
27 views

Using the value of OptionValue to clear a list

I'm currently using OptionValue inside a function, the Option I passed to the function should be cleared, then populated with ...
1
vote
1answer
26 views

Manipulating variables indexed by a list

I have a variable g, indexed by a list: g[{1,1}]=11; g[{1,2}]=12; g[{2,1}]=21; g[{2,2}]=22; I would like to move things around as follows: ...
0
votes
1answer
28 views

Picking out elements from a multi-level list

I have the following problem that is giving me headaches: I have a list with the elements in the following form: {x,{{a1,b1},{a2,b2},{a3,b3}}} I would like to ...
1
vote
1answer
54 views

Is there a function or a way of getting a remainder or modulus with equations with “surds”?

So I'm working with "surds", or radicals. I have expressions like $$7 + 5\sqrt{2} + 6\sqrt{3} + 7\sqrt{6}\tag{1}$$ and I want to take the "coefficients", for lack of a better word, and take their ...
1
vote
2answers
54 views

How can I count only the sublists having more than 9 number of '2'?

I made a table giving me 1's and 2's In[23]:= S = Join[Table[1, 1], Table[2, 1]] Out[23]= {1, 2} And then I made it bigger: ...
3
votes
1answer
60 views

How to access all instances of a defined function

This should have a simple solution, but for some reason I cannot find how to do this. Let's say I have a "function" where I have defined values (in my actual example I have many instances of this, ...
0
votes
0answers
27 views

Creating a special product function

I am having trouble working with lists inside functions with Mathematica. Basically, I have a list of numbers and a special way to multiply them. I want to have a function that is able to create a ...
3
votes
1answer
93 views

Why doesn't DeleteDuplicates do what I want

First off. I am not a mathematician I am a linguist, a syntactician who is trying to say something about semantics, which in the case at hand can be largely understood to reduce to set theory. That ...
0
votes
1answer
28 views

I need to extract data from a multi-valued functions and interpolate them into separate single values functions

The graphed data look like this. I need to extract the data for each curve individually and use Interpolation to create a differentiable function for each curve. Can you show how to do this? I will ...
1
vote
1answer
44 views

How to extract and plot pieces of a multi-valued function

I have multi - valued functions that create lists of data like this: ...
0
votes
1answer
49 views

How to generate a list with elements f[i] for a function of several variables f?

I would like to create an array of length n with each element i equal to the function ...
1
vote
0answers
54 views

Extract values of a ListAnimate plot that are moving at a fixed rate

I have this code which animates a layer of fluid moving on the outside of an ellipse with a moving black point on the cylinder surface itself. Is there a way to find the value of the blue outer line ...
0
votes
1answer
54 views

How to flatten a tensor product

Say I have a tensor product of four two dimensional spaces $\Lambda = S\otimes S\otimes S\otimes S$. The basis of $S$ is CB={{1,0},{0,1}} . I generate the ...
0
votes
1answer
34 views

Delete element from list [closed]

I have a list with 1000 elements, and I want to delete all elements from index 400 (including) until the last element.
7
votes
1answer
100 views

Partitioning a list by cumulated sum when the accumulate reaches a fixed value

I have a list dat = {10, 10, 10, 10, 10, 40} . When the cumulative sum of dat reaches >=...
0
votes
0answers
29 views

Number Form not shown as Matrix Form [closed]

I have a list that I want to show as a Matrix but with its numbers up to 3 decimal places. I have my list: ...
4
votes
1answer
78 views

Select sets from a list which are in ascending order

Given a list of sets I want to choose the sets whose elements are in ascending order. I think I need to use: Select[list, crit] for this problem, but I could not ...
2
votes
1answer
40 views

Use a list with single number for the second input of Table

As you see both inputs below give the same results. Is there any reason to use List[3] instead of just 3 in the first case? <...
3
votes
2answers
95 views

When do functions apply on lists and when they do not

I have read in my lecture notes on Mathematica that functions (in the general sense) can be applied to lists of data and that they can return new lists with data. I have tried this and I have got ...
3
votes
2answers
91 views

Remove a list element based on condition

I have a list with many expressions as elements. I want to remove the list elements which do not contain certain variables. For example, I would like to remove the element which does not contain ...
2
votes
1answer
55 views

Tuples with more criteria

I have seen that there is question here which does almost what I wanted to ask but it's not quite what I wanted. Efficiently generating tuples with Outer What I would like to have is a Tuples of a ...
1
vote
2answers
33 views

Manipulation replacements rules from Solve [closed]

Assume the call to the routine Solve[eqn==0,{x1,x2}] returns: {{x1->a1,x2->a2},{x1->b1,x2->b2}} I would like to ...
2
votes
1answer
30 views

Taking Out Max List from List of Lists

I have a list like this: L1 = {{500, {x->3, y-> 4, z -> 1}}, {110, {x->11, y->41, z -> 9}}, {750, {x-> 1, y->-1, z->0}}} Is there a ...
0
votes
2answers
28 views

How to create seperate empty lists assigned to seperate variables

Instead of doing l1 = {} l2 = {} Is there a way to incorporate a loop to make this process faster?
2
votes
2answers
48 views

How to iterate through a lists of lists and delete a certain element?

Say I have a list of lists such as l1 = {{a, 2}, {a, 5}, {b, 3}, {b, 9}} How would I iterate through the list and delete all the lists with the first element b ...
0
votes
1answer
41 views

How do I split up a list of data points into invervals and assign values to those intervals?

So I have a data set for chess and our goal is to plot the difference between the rating difference versus white's win rate. I want to subdivide the x-axis into intervals like (-10, 0) (10,20) (20,30)...
3
votes
1answer
46 views

How to add ± to each element in the List?

I just want to add ± with Function Thread Output that I want {±1, ±2, ±3, ±5, ±7, ±9} ...
3
votes
2answers
81 views

Replace the diagonal of a list of matrices

I want to replace the diagonal of a square list of matrices with another list of matrices. What is the fastest and most efficient way to do so. (I will need to do this for very large arrays) Small ...
0
votes
1answer
62 views

Finding the maximal number of lists that form certain rules?

I have the following example: data={1, 2, 3, 4, 5, 6, 7, 8, 9}; NN=Length[data]/3; subdata=Subsets[data, {3}]; I want to know all the possibility for the ...
1
vote
1answer
31 views
2
votes
2answers
53 views

Generating Logical Constraints from a List

I have an equation, call it l1, that looks like this: e1 = x*y*z + t*u*v + a*b*c I was wondering if it would be possible to generate a boolean expression like ...
2
votes
2answers
65 views

Triangular matrices with conditions

I would like to generate a lower triangular matrix that has checkmarks in the non-zero entries. The way that I created this matrix is the following ...
2
votes
1answer
95 views

Implement gradient method in functional programming style

I implemented the gm for quadratic function in Mathematica, but it looks like more in an OOP style, as the pic shows. How to rewrite it in Mathematica style? I tried with following code: ...
3
votes
2answers
66 views

Problem with Inserting in a Nested list

So I have a nested list like this: {{{0}},{{0}},{{0}}} Now i need to Insert in the first sublist like this ...
3
votes
1answer
50 views

Generating And / Or Conditions Automatically from a List

I have the following list: l1 = {x y, s t, a b} From this list, I am trying to essentially generate a new list that looks like this: ...
0
votes
3answers
49 views

How to obtain the minimal index n in a list (A) so that Total[A[[1;;n]]] is bigger than a specific value m?

Imagine the A array is {1,2,3,4,5,1,2} and m = 4. Then in this case, Total[A[[1;;3]]] is 6, ...
0
votes
0answers
29 views

Differentiation of a series with unknown coefficients

I have a function $f(x)$ expressed as $$f(x) = \sum_{k=1}^n {a_k}sin(kx)$$ and its derivative with respect to $x$ is then $$f'(x) = \sum_{k=1}^n k{a_k}cos(kx)$$ I am actually new to Mathematica and ...
5
votes
1answer
253 views

Removing Shorter Subsets in List of Lists

I have in Mathematica a list of lists like this: ...
1
vote
1answer
72 views

How to return the equal points between two lists

I have something like this ...
4
votes
1answer
55 views

Map list of functions over list of inputs

Given a list of functions {f1, f2, f3, ...} and list of inputs {1, 2, 3, ...} I wish to produce the list ...
3
votes
1answer
42 views

How to efficiently select positions of elements in a sublist

Apologies if this is an already answered question, I was unable to find anything until now. I believe the answer will be quite simple, I have just been stuck on it for a few days now. I have a large ...
1
vote
1answer
56 views

Element-wise minimum of two matrices

I am trying to compare two identically-shaped matrices and select the minimum of the two. This is an extension of a past question: Element-wise max of two lists, except I have three nested lists. <...
1
vote
1answer
36 views

Part Assignment of variables with argument

I do not really understand why this: a = {1, 2, 3}; a[[1]] = 3; a {3,2,3} works as desired, but this does not: ...
0
votes
1answer
37 views

Importing a 3 dimensional list

I have a code that is generating some numerical data in the form of a list of trajectories. Each trajectory itself is a list of 2D coordinates. Each coord. is a list of 2 numbers.(see example data ...
2
votes
2answers
79 views

Create a list of the first 100 deficient numbers

For the purposes of the assignment, I need these values in a table. We have so far only used for/while loops to check the deficiency or abundance of certain types of numbers. I initially tried using a ...
1
vote
0answers
34 views

Transpose two lists with rightarrow and commas [closed]

I need to transpose the two following lists: data0 = {99.52267, 93.78726, 99.67644, 99.85036}; error0 = {0.21152, 0.37626, 0.16309, 0.10167}; Into ...
2
votes
1answer
38 views

Interpolating and subtracting two sets of data

I have a data set "data9k" with x varying from 0 to 365, and another data "data0" set with x varying from 0 to 365. But the x values for both data sets are not same but similar. I want to subtract the ...
2
votes
1answer
54 views

How can a set of rules be applied to edit strings within a list of lists while maintaining list structure?

In attempting to read a webpage ("https://www.house.gov/representatives#by-name") I have managed to import a table using ...