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
0
votes
0answers
38 views

calculate differences of a list using slots

I want to calculate the differences between the numbers of a list. One way to do that is using 'Differences'. For example: L = {1, 3, 6, 9}; Differences[L] this ...
4
votes
2answers
129 views

Integrate function returns vector instead of scalar

When I try to integrate a function mapping a vector to a scalar Mathematica "ignores" the function and returns a vector independent of the function. Here is a minimal example of my problem: ...
3
votes
1answer
61 views

Return the factors of a partially-factored polynomial, without factoring

Suppose I have an integer polynomial f that is in a factored form, say f = (1 + x) * (2 + x + x^3) * (2 + x^5). I want a ...
4
votes
1answer
121 views

How to filter table from some rows without flattening it?

Consider the following table: a1[x_] = If[x < 1.1, 3, Pi/2] tabb = ParallelTable[{x, y, z, a1[x]}, {x, 1, 2, 0.1}, {y, 0.5, 1, 0.1}, {z, 1, 3, 1}] Here, a1[...
0
votes
2answers
46 views

How can I transform the string to a list?

As you can see from the picture, when I use StringReplace function, the list is converted to a string. How can I get the list form back? And the String "-" is necessary (Cuz I just know one ...
1
vote
1answer
31 views

Reading off coefficients as array

Suppose I have a series expansion with non-associative characters, i.e., $1**2**3**4**5 + 2**3**4**5**1 + \cdots$ Then I want to make some array which produces $A[1]= \{1,2,3,4, 5\}, A[2]=\{2,3,4,5,1\...
1
vote
1answer
28 views

Call part of a replaced list

I have what I believe to be a very simple problem. I want to use an equation which depends on the values inside a list, but to be able to evaluate that equation with different lists. So: ...
16
votes
1answer
260 views

Head[x] vs x[[0]]

Can we say Head[x] and x[[0]] are identical ? In mathematica manual I could find : 'The head is the part with index 0' But I am not sure whether Head[x] are x[[0]] are really interchangeable in any ...
0
votes
1answer
53 views

Checking variable A is determined. (DeterminedQ ?)

How can we (loosely) check whether variable A is determined, not directly computing A ? (= How can we define DeterminedQ function ?) For example, ...
5
votes
2answers
117 views

Delete complex conjugate in a list

I have a list with complex numbers. I would like to delete a number $z$ that is in my list if at least one of these conditions is met: $-z$ is also in the list $\bar{z}$ is in the list $-\bar{z}$ is ...
4
votes
3answers
94 views

Cases in list with varying length in sublists

Given t1 = {{14, {{1, 2, 3}}}, {15, {}}, {16, {{0, 0, 4}}}, {17, {{0, 1, 4}, {2, 2, 3}}}, {18, {{0, 3, 3}, {1, 1, 4}}}, {u, {{1, 0, 2}, {2, 3, 0}, {2, 3, 4}}}} I ...
1
vote
1answer
67 views

Manipulate mapping on lists

For some function f, consider the following expression: ...
3
votes
1answer
64 views

Distribute a nested list

I would need a function that distributes a nested list in a specified position. A sample of this function could be: ...
3
votes
2answers
77 views

Generating representatives of rotation classes of tuples of ones and zeros with a fixed number of ones

In a related question I asked how to generate all the tuples of ones and zeroes with a fixed number of ones (generating tuples of ones and zeroes with a fixed number of ones). I wish to consider a ...
7
votes
2answers
200 views

How Can I Compute The Automorphism Group of a Matroid?

I want to compute the automorphism group of a matroid. This reduces to the following (more general) problem: Suppose I have a list of sets $\{\{b_{11},\dots,b_{1k}\},\dots,\{b_{k1},\dots,b_{kk}\}\}$ ...
2
votes
1answer
51 views

How to use IntegerQ on list?

t1 ={0, 1, 2, Log[6]/Log[2], 3, Log[12]/Log[2], 4, Log[24]/Log[2]} I want to get the Position of the Integers. I can do it by <...
5
votes
4answers
293 views

How to map a function with boolean operators over an array?

I am a beginner in Mathematica. I have this in Mathematica v12: A = {1, 1, 1, 1} B = {2, 2, 2, 2} A+B (* 3,3,3,3 *) I'd like to experiment with evaluating ...
5
votes
3answers
367 views

Fastest way : two by two list inversion

Consider a list of even length, for example list={1,2,3,4,5,6,7,8} what is the fastest way to accomplish both these operations ? Operation 1: two by two element ...
6
votes
4answers
122 views

Check if list is singleton in sub linear time

A singleton is a list whose elements are equal. Some ways of checking this in Mathematica: {Equal@@#&, 1==Length@Union@#&, MatchQ[#,{x_ ..}]&} I ...
9
votes
6answers
384 views

generating tuples of ones and zeroes with a fixed number of ones

I would like to generate all the tuples of ones and zeros of a given length and with a given number of ones without generating all the possible tuples, which is impossible for tuples of large enough ...
1
vote
1answer
34 views

How to convert element's Table to List / Array to make an independent multivariable fit?

I would like to make an independent multivariable fit, but I have problems using a Table that I generated. I can´t use their elements because it isn´t in a list or a rectangular array. Using Table[ ] ...
0
votes
0answers
23 views

How to set PDE coefficient as a list of discrete data

How to set a pde time-dependent coefficient, not as an analytic function in time, but as a discrete data vector or list, each element of that list represents the coefficient value on a specific time ...
0
votes
1answer
47 views

Speeding up Do loop with lists inside

The question is simple. I'm trying to improve the (time) performance of a "Do" loop that looks like the following MWE ...
1
vote
1answer
129 views

How to efficiently replace the repetitive sequence?

The problem is how to determine the repetitive sequences and replace the part with consecutive sequences For example: A={{1,3,4},{2,3,5},{1,6}} Then, detect there ...
2
votes
1answer
69 views

Another basic question on list manipulation [closed]

Suppose you have a list of triples: A = {{x1,y1,z1},{x2,y2,z2},{x3,y3,z3}} How do we find x such that z is the maximum?
2
votes
3answers
205 views

Basic manipulations with lists

Suppose I have a list of the following form: List={{{a,b,c},{d,e,f},{g,h,i}},{{j,k,l},{m,n,o},{p,q,r}}} I have two questions: A) How can I convert this to a list ...
0
votes
1answer
68 views

Why won't Sequence work when wrapping a list of arguments for deletion with Remove?

I wrote a quick and dirty little function freshStart which does a variety of things meant to give me a nearly fresh Kernel without having to ...
3
votes
1answer
49 views

warning in Position + IntersectingQ

Why there is a warning message (with correct output) for the following code ? ...
0
votes
1answer
47 views

Sorting terms in a huge equation by grouping specific products

I have a boundary condition for a problem, which contains around 100 terms! I have no trouble getting Mathematica to compute it, but the terms are sorted in a seemingly random order and I would like ...
1
vote
0answers
30 views

How to select only non-numeric data from the mixed table [closed]

Consider the following data: data={{1,2,3},{2,3,4},{1,5,Some symbols},{00,230,Some other symbols}} where "Some symbols" is something arbitrary (say, a ...
3
votes
1answer
36 views

Using Apply or unpacking lists for only some arguments of a function [duplicate]

Say I have a function f of three parameters and a list l = {b,c}. I want to pass the first parameter to ...
10
votes
2answers
235 views

Efficient method to find a pair that sum to a given value in a list in matematica style

Given an array nums and an number target, find all pairs in array whose sum is equal to ...
0
votes
1answer
51 views

Comparing and finding element of a list [closed]

Let's say i have a list tab1={{0.378377, 1.58249*10^-11}, {0.44749, 1.03208*10^-13}, {0.513543, 2.13122*10^16}, {0.505355, 7.12295*10^16}} and i would like to find ...
0
votes
1answer
69 views

How should I export data with desired precision to output file

I want to control the number of decimal points in the output file. ...
1
vote
2answers
60 views

Binomial like multiplication of elements of a list

Given a list p = {0.10715, 0.08058, 0.00360, 0.00183} how to implement function that does: ...
1
vote
1answer
45 views

Find maximal elements of list (remove dominated elements)

Suppose I consider a to be greater than b if a[[1]] >= b[[1]] and ...
1
vote
0answers
60 views

List mean and standard deviation [closed]

I have a list indexk (in=Head[indexk] out=List) its dimensions (in=Dimensions[indexk] ...
0
votes
1answer
58 views

How to efficiently find elements in list A that aren't in list B?

Every element in List A appears only once, and the same is true for List B. How can I efficiently create a list of the element in A that don't appear in B? Obviously, I can just do this: ...
2
votes
4answers
133 views

Plotting after solving equations

I obtained a list of Y list after using Table[NSolve[expression,X],{var,varmin,varmax,step}]. Then I created a list of X with ...
1
vote
1answer
69 views

How to use 'Join' and '& /@' : combining all .csv files in a directory into a single .csv file automatically

I would like to import all .csv files in a directory and combine them into a single file using Join. I can do this manually but when I try to automate it using <...
2
votes
3answers
167 views

How to join points {x1,y1} and {x2,y2} only if x2-x1==1

Given list={{5, 3}, {9, 5}, {10, 4}, {11, 3}, {13, 3}, {14, 4}} I want to ListPlot these points and use ...
2
votes
0answers
49 views

Handling lists indexed with integer partitions

I am trying to do some exploration around the multi-dimensional version of [truncated moment problem], where I work with various distributions (uni- or multi-variate), and use some truncated moment ...
2
votes
3answers
107 views

Sophisticated read data from .txt file

I have following .txt file: ...
9
votes
1answer
182 views

Strictly Increasing Sequences of Length n in a List

I need to determine how many strictly increasing sequences of a certain length (e.g. 5) are contained in a list of integers. I would be very happy if someone could help me. A sequence would be ...
3
votes
3answers
171 views

Create list of rules from list [duplicate]

I want to create a dispatch list (list of rules to replace parameters) from a standard list. I have an equation which depends on a, b, c, d. I want to pass lots of different values from a data set. ...
0
votes
1answer
54 views

Part Specification is longer than depth of object & Transposing Errors

In trying to recreate results from another question I had asked (here) Code is: ...
3
votes
3answers
73 views

How to delete consecutive commas in an imported array in Mathematica?

I am importing an excel sheet into Mathematica. The result is a rectangular array. The array contains sequences of commas. Whenever a cell is empty in the Excel sheet consecutive commas appear in the ...
4
votes
2answers
69 views

From list to unique ID number AND back

If I have a series of list of the form $L_k=\{a_1, a_2,...a_n\}_k$ with $-4<a_i<4$ and $a_i\in\mathbb Z$, then I can make a unique ID number for $L_k$ using ...
1
vote
1answer
34 views

using a list of parameters in NSum [closed]

I am trying to make a function that uses NSum, that takes a list of parameters. But NSum doesn't appear to play nicely with lists. A minimum working example is: ...
11
votes
4answers
539 views

Scan through (partial) tuples

I have a list of list of positive integers $s = \{s_1, s_2, ..., s_k\}$, each list $s_i$ is possibly of different lengths, and I want to find out if there exists a $k$-tuple of the $s_i$ that sums ...

1
3 4
5
6 7
142