# Questions tagged [list-manipulation]

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

7,205 questions
Filter by
Sorted by
Tagged with
53 views

### Enumerate all possible subsets such that all are of the same length which is maximum and each contains non-repeating elements?

Given a list lists: ...
72 views

### NMinimize over a list of integers

I'd like to minimize some function (of 3-4 variables) over a big list of integers, but not consecutive. Like arr = {5, 10, 7, 101,...} I did not understand this ...
164 views

### An operation on a list [closed]

I have a nested list, and I want each sublist to be connected by a <-> symbol between the first and third elements and between the second and fourth elements. For example, ...
309 views

### List rearranged

I have a very long list from which I will display part of it as, a={{1, {3, 5, 8, 9}}, {2, {4, 6}}, {6, {1}}, {10, {1, 3, 5, 6, 7, 8}}}; For plotting purposes, I ...
85 views

### Swapping items in a table

I have a code that generates various tables like ...
79 views

### Transforming a checkerboard using Transpose and ReshapeLayers

In the paper for RealNVP, they introduce a "squeezing" operation that takes a matrix and transforms it to have more channels, according to the following transformation (before and after): As you can ...
87 views

### how to change list of some scalars into vectors?

I have a pair of equations f= {eq1,eq2} that are (x,y) dependent. I take derivative by (x) and (y) for each equation, for example, Grad[f, {x, y}] . {1, 1}] and ...
85 views

### Dropping specific elements from list

list[1] = {{1, 1, 0}, {1, 0, 1}, {0, 1, 1}, {-1, 1, 0}, {1, -1, 0}, {-1, -1, 0}, {-1, 0, 1}, {1, 0, -1}, {-1, 0, -1}, {0, -1, 1}, {0, 1, -1}, {0, -1, -1}}; ...
33 views

### How do I input n-Dimensional random numbers into a function accepting n variables [closed]

Apologies if this is overly simple but I wasn't able to find an answer online. Question Say I have a function defined as follows (and not two separate instances of random numbers), ...
81 views

### Lists of labelled vectors, how to output a list of tuples which sum to zero

list = {{1, 1, 0}, {1, 0, 1}, {0, 1, 1}, {-1, 1, 0}, {1, -1, 0}, {-1, -1, 0}, {-1, 0, 1}, {1, 0,-1}, {-1, 0, -1}, {0, -1, 1}, {0, 1, -1}, {0, -1, -1}}; list2 = {{2, 0, 0}, {0, 2, 0}, {0, 0, 2}, {-2, ...
52 views

### Delete rows from 3D matrix and convert it to 2D matrix

I have a 3d matrix of dimension $11 \times 1000 \times 3$. I need to remove the first 10 rows from all 2D matrix so that the output is $11 \times 990 \times 3$. After that I need to convert it into a ...
50 views

### Find Columns That Match Row Vectors in a Matrix

Suppose I have the following matrix whose row elements are given by the data listed below. ...
85 views

### List of lists with non-repeating elements

I have the following lists: l1 = {{a,b},{a,c},{a,d},{a,e},{a,f}}; l2 = {{b,c},{b,d},{b,e},{b,f}}; l3 = {{c,d},{c,e},{c,f}}; l4 = {{d,e},{d,f}}; l5 = {e,f}; I want ...
65 views

### Deleting all elements in a list where the output of elements from a function is zero

I tried using DeleteCases to delete elements in r1 where g2==0 to get a defined arithmetic ...
63 views

### How to convert list to cycles? [closed]

My code below returns the list: {1, 3, 2, 4}. I want the disjoint cycle representation of this permutation. In other words, I want: ...
69 views

### Boundaries problem with listdensityplot

I have to following list to plot (from FEM software) {coord xi, coord yi, speed (norm of) vi} : ...
152 views

### How to convert $a(x-p)^2+q$ to $a(x-\alpha+i\beta)(x-\alpha-i\beta)$ for any real $a$, $p$ and $q$ [duplicate]

I want to factorize any quadratic expressions into two complex-valued linear expressions. My effort below ...
216 views

How to calculate Numerical gradient of 2D arrays using the "gradient function" ("Matlab-like")? "[___] = gradient(F,hx,hy,...,hN) specifies N spacing parameters for the ...
92 views

### Map Function with Table on each row

I need help as I am new to Mathematica. I have a table with some nominal bond values: ...
149 views

### Duplicate each element sublist

I have a list of the form {{0,0},{0,1},{1,0},{1,1}} and I want to duplicate each of its elements, i.e. ...
137 views

### How can I speed up this pdf path integration calculation with a slow recursive function with 40^4 summed terms in each iteration?

I am writing a path integration code for a numerical approximation to a probability density function. I essentially take some initial continuous probability density function p0 and then perform a ...
59 views

### "Total" function for a Boolean expression

I have a very long vector of the form ...
71 views

### Unexpected behavior when adding UnitVector to vector (list)

The expression {v1,v2} + UnitVector[2,x] evaluates to {v1 + UnitVector[2, x], v2 + UnitVector[2, x]} but that is suddenly a ...
63 views

The possible values to specify the Padding option of a PaddingLayer include a fixed value, ...
468 views

### GroupBy sometimes deletes values

GroupBy[{1, 1, 1, 1, 1, 1}, # > RandomReal[{0, 2}] &] sometimes returns something like ...
509 views

### Mathematica 12.x: Don't use Accumulate or Differences on Around objects!

Bug introduced in 12.0 or earlier and persisting through 12.2 or later It seems we've discovered a bug! The following is a summary of the problem and possible workarounds. Scroll down to ORIGINAL ...
68 views

### How does this FromDigit module work?

I am entering the following input: ...
88 views

123 views

...
50 views

### Why if I change the function Sine to discrete Sine the plot is difference

I would like to know why when I change +1 in a discrete Sine change the list line plot and when I plot the function sine anything change. ...
82 views

### restructure a list with brackets

I work with the following list data = {{a}, {{a, b}, {a, b}}, {{{a, b, c}}}}; In real, the dataset is much longer and each row has a different structure of having {...
31 views

### Question about a restricted rewrite rule [closed]

I just started learning Mathematica and I'm not sure why a function I defined doesn't work. So I'm trying to write a function that takes a list of vectors and eliminates all zero vectors (with respect ...
37 views

### Replace part of list by applying operation to it [closed]

I want to replace, say, list[[i]] by f@list[[i]]. I can use ReplacePart as below, but I ...
85 views

### Unable to operate on the table imported from .mx file

I saved a table by exporting it to .mx file. Now, when I import it back, it gives me the desired output. So, to work with elements of the table, I first define the imported table as (...
543 views

### How to generate all possible functions combinations

Assume that I have 3 functions like this (total 10 functions in reality). f1[x_] := 3 x; f2[x_] := x^2 - 1; f3[x_] := 2 x + 5; Now I want to generate all possible ...
206 views

### List manipulation: all possible sublists

Say I have the following list {a,{b,c},{d,f,g},e} what is the fastest way to get the result lists ...
92 views

### Why does this DeleteCases not work? [duplicate]

I believe this is simple but I couldn't figure out why this doesn't work. Everything looks good to me. ...
61 views

### Palindrome by deleting a character

I need to find a list of strings with input string length n for whom are palindrome by deleting a character from it . The strings are stored inside function ...