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
1
vote
1answer
39 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
58 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
42 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 ...
1
vote
0answers
48 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
45 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
58 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
188 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
47 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
105 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
61 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
42 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
42 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
196 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
55 views
0
votes
0answers
41 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
123 views

Deleting list members by rule

I have a list: ...
4
votes
3answers
78 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
34 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 ...
0
votes
0answers
14 views

Printing two list matching each element [closed]

If have a function k[{a_, b_}] and I would like to print each tupla Tuples[{0,1},2] with each solution of the function Map[k, Tuples[{0, 1}, 2]] Something like: {0,0} -> k[{0, 0}] {0,1} -> k[{0, ...
3
votes
1answer
46 views

Converting Association to Matrix

Imagine I have the following association, where the keys are given as pairs of natural numbers ...
2
votes
1answer
48 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
49 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
57 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
32 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
143 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
48 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
49 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
51 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
45 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
171 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
73 views

How to build my desire matrix using SparseArray?

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

Looking for a Compilable Form of DeleteDuplicates

Union is Compilable but DeleteDuplicates Isn't?! First, DeleteDuplicates is not compilable ...
4
votes
1answer
259 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
120 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
65 views

deleting a pattern from a list

I have a list: ...
2
votes
2answers
83 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
88 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 ...
-1
votes
0answers
89 views

Creating An Input That Crushes The Application and/or Computer?

Dear StackExchange Users, Can anyone assist me in creating a line of input that will malfunction the Wolfram Mathematica 12.3 application (and ideally the computer) when it executes/been executed? In ...
2
votes
4answers
211 views

Use replacePart from an element n to an element m of a list

I would like to replace a part of a list from an element n to an element m by zeros. I believe the function ReplacePart could be useful Example: I want to replace elements from 2 to 4 by zeros : ...
1
vote
0answers
25 views

What subsequences does SequenceReplace consider

Consider SequenceReplace[{a, b, x, x, a, c}, {a, e_} :> e]. What subsequences does SequenceReplace consider? The ...
0
votes
1answer
59 views

Using :> vs -> in SequenceReplace

The first example on the page for SequenceReplace is the following: SequenceReplace[{a, b, x, x, a, c}, {a, e_} :> e] ...
7
votes
3answers
317 views

Flatten simple list

I know this is probably a very silly question but I am trying to get {x,y,z,p} to be x,y,z,p. For this I am using Flatten in this way: ...
2
votes
2answers
51 views

creation of sublists by rules

I have a list consisting mixed strings and numbers: ...
0
votes
3answers
275 views

Python recursive bisection algorithm to Mathematica

I've been sitting on this problem for a while and i am kind of stuck. I am pretty new to Mathematica and have been trying to implement a recusive Algorithm, which splits/bisects a list of items in ...
3
votes
3answers
302 views

How to find a median of odd and even numbers from a list of numbers

For a given list, say {94,35,47,29,86,40,46,72,87}, how can I find a list of even and odd numbers. Here is the output after trying with the suggested solution in the answer. After putting the number ...
3
votes
1answer
111 views

Sublist creation, splitting and joining

I have a not very usefully-formatted string list and I would like to create certain sublists from it. ...
0
votes
1answer
33 views

ComplexListPlot not ploting [closed]

In a nutshell i have to plot a sequence of complex numbers to roughly see if it converges or not. I've created the list using the following ...
0
votes
1answer
26 views

How to deploy cloud application that graphs two companies net profit

What I want to do is to deploy a cloud application that would compare two stocks and (for bonus if it is possible) to also compare the net profit of two companies on a graph. I tried: ...
5
votes
3answers
167 views

Extract specific string from a list of strings

My question is similiar to previous questions (see here or here), although the issue is maybe somewhat more complicated: I have a list with strings like this: ...

1
2 3 4 5
145