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
5
votes
3answers
126 views

Listing all Index Possibilities Given a Vector and Indexed Set

Let's say I am given a vector $v=(5,2,-2,-4,3)^T$ and $\alpha \in \{-1,1\} $. I want to find all indices $(\alpha,i)$ such that $\alpha v_i >0$, where $v_i$ is the $i$th entry of the vector $v$ ...
2
votes
1answer
41 views

how do delete elements from a list that occur before a defined sequence of elements

A simple question: I have a list lis = {a,b,c,d,e,f,c,d} I need to delete all the items in the list that occur before the first appearance of "c,d" to ...
6
votes
3answers
284 views

How to organize a list of dates

I have a list of daily measurements taken on given dates, where the measurements follow the dates: ...
0
votes
0answers
51 views

Assign values from Table to a list

I am trying to make a set of initial conditions - {x0, y0, z0} using transformation : ...
6
votes
5answers
339 views

Replace a range of elements in a list with another list

For example, there's a list {0, ..., 0} of length n. Can I replace the first six elements with the elements of another list of length 6?
2
votes
1answer
52 views

Convert a specific column to Dateobjects

I have searched around but haven't found an answer to the following problem. I have a spreadsheet with a large number of rows and 4 columns. Column 3 contains dates not in a right format. So I want to ...
1
vote
0answers
27 views

Plotting arrays with increasing color intensity in ListPlot [duplicate]

Suppose I have a few 2-dimensional arrays I want to plot together, ListPlot[{arr1,arr2,arr3,arr4...}] I would like to give each one a different shade of the same ...
2
votes
3answers
137 views

Obtain Data Points (x,y) from a 2D region plot generated from an inequality

I have a code that generates a region plot modeling an aperture. I would like to generate a table of ordered pairs (x,y) for a given u that manipulates my inequality. When I attempt to great a table ...
3
votes
4answers
194 views

List all substrings of a number

Need some help listing all substrings of a number X=219 The output should be Output= {2,21,219,1,19,9} Order does not matter for this problem Any help is appreciated
1
vote
2answers
105 views

Simple DO structure command

Excuse the simple question, I have the following structure: t = {}; Do[f[z_] := Sin[z]; Sol1 = z f[z]; AppendTo[t, Re[Sol1]];, {z, -4, 4, 3/4}, {p, {10}}]; t ...
1
vote
1answer
45 views

selective removal of list members

https://mathematica.stackexchange.com/questions/256041/selective-removal-from-a-list/256053#256053[1] In reference to the above question, I apologize but I've posed the question incorrectly. Let me ...
2
votes
4answers
210 views

Multiple place holders in a Select command appear awkward. Asking if ok

I have a nested array for example: myVals = {{1, 2, 3, 4, 5, 6}, {20, 20, 21, 3, 15, 7}, {2, 3, 35, 106}}; And suppose I want to select in each sub-array, all ...
3
votes
3answers
110 views

selective removal from a list

I have a list whose elements consist of a date object followed by several integers: ...
3
votes
1answer
74 views

How to use wildcards in SequenceCases

The final task is to revise the question I posed at list rearrangement: I now start with this list: ...
3
votes
3answers
112 views

sublist creation by string pattern

I have a list: lis = {1, {"AB", 2, 3}, {"ABC", 8, 9}, {"BC", 7}}; ...and I would like to make a new list consisting of all elements ...
1
vote
1answer
51 views

how can I get the general expression of the outer product of n sublists?

There is a large list, with $n$ sublists of the same length (e.g. length is 3). list1 = {{a_1, b_1, c_1}, {a_2, b_2, c_2},..., {a_n, b_n, c_n}} If I need to regard ...
2
votes
0answers
74 views

How to use Select and MemberQ together with Map correctly?

I have a list with quite a few elements. Each element is a rule of the type vector-> number such as {1,2,3,4}->1.435 and ...
1
vote
2answers
50 views

How to append arbitary list with {0} so that its length becomes a given integer k [closed]

How to append arbitary list with {0} so that its length becomes a given integer k? For example, when ...
3
votes
2answers
91 views

Rearranging a table

I have a table, say, with about 1000 rows and 6 columns. Out of six elements in a row, first two are independent parameters, while rest four are dependent parameters. Say, the header of the table is <...
5
votes
3answers
213 views

list rearrangement

I have a list: lis = {{1,2,3},{"True",3,4,5},{6,5},{3},{6,4},{"True",2,1},{5},{5,6},{7,8,9}} I want to make a new list consisting of elements ...
1
vote
1answer
52 views

How to do simple list traversal? And how do I insert this in a function?

I want to make a function that takes as input a list of numbers and returns a list of 4 lists; the first returned list holds all positive real; the second returned list all negative real; the third ...
2
votes
2answers
121 views

Really slow evaluation of a simple? list expression

I believe this is a standard problem, but I could not find a solution anywhere. Possibly because I don't know what to look for. I define a subset of some numbers and I want to count how many are less ...
2
votes
1answer
70 views

Minimizing functional using FindMinimum

Suppose you are given some functional $S$, (with some 'Lagrangian' $L$) $$S[f]=\int_{t_i}^{t_f}L[f(t),f'(t)]dt$$ and you want to find the function $f$ that minimizes it, subject to some boundary ...
0
votes
0answers
53 views

Inverse/Division in finite field?

Think of multiplictavie group of finite field F[p,n], where p is a prime number and n is a positive integer. The whole elements of F[p,n] can be represented as p^n-p^(n-1) positive integers in the ...
1
vote
0answers
55 views

How to create this list

Suppose I have two kinds of operators $a[i,j],a^\dagger[i,j]$ where i is a non-negative integer and $j=\pm 1$, I want to create a list containing all possible products of $ a^{(\dagger)}[x_1,j_1]a^{(\...
5
votes
4answers
350 views

Combine sublists of nested list when the first two list elements are equal

New to Mathematica, I have a nested list with the following structure: { {A,B,C,D,E,F},{a,b,c,d,e,f},{G,H,I,J,K,L},.......} All sublists are of equal length. I ...
0
votes
1answer
60 views

Function of a list does not evaluate if list has more than 1 element

I have the function: ...
0
votes
0answers
45 views

Matching two lists and create variables

I have two lists of the same length. One of the lists has all the variable-names in it and the other one is a list of lists in which each list represents a value. I now want to automatically create as ...
4
votes
2answers
148 views

Deleting list members by rule

I have a list: ...
4
votes
3answers
90 views

Extracting row from specific value [closed]

I have a multiple datasets that contains thousands of rows and thousands of columns, and from that I'm trying to extract the row that contains the smallest column value from the entire dataset. ...
2
votes
0answers
36 views

Finding Position of a Nested List By A Value Test [closed]

What I am looking for is an understanding of why what seems to me a straightforward extension of finding elements in lists does not extend (without returning error messages) to nested lists. A couple ...
3
votes
1answer
53 views

Converting Association to Matrix

Imagine I have the following association, where the keys are given as pairs of natural numbers ...
2
votes
1answer
51 views

How to correctly take an element of a vector-valued function?

I have a vector-valued function whose arguments, for some reasons, are forced to be numeric by adding ?NumericQ. I can correctly take a particular element of the ...
1
vote
1answer
53 views

Grouping together same exponent terms in a multivariate monomial

This is a rather simple question but for some reason, I am spending too much time on this. Suppose I have a monomial in 4 variables, each raised to some linear combination of 3 exponent variables: <...
1
vote
1answer
59 views

How to list all solutions appearing in range [duplicate]

A function h that I've written (it uses Reduce) outputs a list of integer solutions of the form e.g. ...
2
votes
0answers
36 views

Replace element within a list of lists with MemberQ condition [closed]

I'm trying to replace the second element within a list of ordered pairs depending on whether that ordered pair exists within another set. ...
4
votes
0answers
154 views

Inconsistent Output Bug and Code-Quits-Kernel Bug with Compile

This is the strangest bug I've encountered. In my experience, variations in the code will unexpectedly crash the kernel, give inconsistent output, or produce expected results with no problems. 1) Code-...
3
votes
1answer
53 views

Advanced List selection by strings when preprocessing data

Below is a sample of the data I'm preprocessing. It's longer in both dimensions than what's shown. I already have a list of the string entries I want and now need grab the rows of numeric data ...
1
vote
0answers
56 views

How can I extract a sub matrix of order 4*4 from four 2*2 corner blocks of a 6*6 matrix? [closed]

Let mat = RandomInteger[10, {6, 6}]; mat // MatrixForm I can access elements as follows ...
1
vote
0answers
54 views

Map a function that uses the lists indices as arguments

Suppose I have a function f[x_] that I want to Map over somelist (assumed to be one ...
0
votes
1answer
47 views

Finding the first few permutations of a list

Given a list, possibly with repeated elements, I am trying to get a list that consists of a specified number of distinct permutations of the list. Essentially, I want to something that works like <...
5
votes
4answers
178 views

Calculate the average with weight

I have a list: list = {{17, 2}, {11.55, 3}, {18.5, 1}, {14.2, 1}, {14.25, 2}, {11.5,3}, {15, 2}, {11, 3},{10.8, 3}}; I wish to calculate: ...
0
votes
2answers
82 views

How to build my desire matrix using SparseArray?

I have built some lists as follows: ...
9
votes
2answers
199 views

Looking for a Compilable Form of DeleteDuplicates

Union is Compilable but DeleteDuplicates Isn't?! First, DeleteDuplicates is not compilable ...
4
votes
1answer
273 views

Largest k such that p^k divides n

(Here all variables are integer.) Is there a built-in function f[n,p] such that f[n,p] = largest k such that p^k divides n For ...
4
votes
2answers
135 views

Cases to identify the sublists, within the list that contain an integer and its square somewhere in the list

Use Cases to identify the sublists, within the list below, that contain an integer and its square somewhere in the list. (Hint: Use the BlankNullSequence and the named BlankSequence patterns with a ...
3
votes
1answer
71 views

deleting a pattern from a list

I have a list: ...
2
votes
2answers
93 views

How to implement If criteria for the NestList-Function

I have a function which bisects a list in two parts recursively. Unfortunately I have to select a number of iterations for the NesList-function which is just an ...
2
votes
2answers
96 views

Select elements from a list of of couples [closed]

I have a list which looks like a={{0., 2.}, {0.2, 1.96041}, {0.4, 1.9216}, {0.6, 1.88355}, {0.8, 1.8463},...} and I want to select all the n^th couples contained ...