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
2 answers
87 views

How do you remove parts of an element within a list?

I have a data set that is something like: time={-2_ms, -1_ms, 0_ms, 1_ms, 2_ms}; How do I drop the _ms part such that its just a list of numbers?
Alex Wong's user avatar
0 votes
2 answers
33 views

How can I DeleteDuplicates in this output list?

In this code, I use DeleteDuplicates, but I still get Duplicates in Output. ...
minhthien_2016's user avatar
0 votes
1 answer
58 views

How can I use MapApply[f] into this list?

I have a list list = {{-5, -5, 6}, {-5, -4, 7}, {-5, -3, 5}}; I tried ...
John Paul Peter's user avatar
0 votes
1 answer
59 views

ListSliceDensityPlot with CSV

I am trying to plot a 4 column (CSV) x,y,z,f file with the ListSliceDensityPlot function for z = 1 But it does not work ...
Blaacklog's user avatar
0 votes
0 answers
58 views

Total applied to the lists: length of the object

My goal is to evaluate the total of each line of the following list: ...
user96773's user avatar
2 votes
1 answer
76 views

Tell Mathematica that the output of a function is a List / Vector

I have a function (Piecewise) that returns a list, e.g.: F[x_] := Piecewise[{{{x^2, x}, x < 0}, {{x, x^2}, x > 0}}, {0, 0}]; I would like to add another list ...
Luis's user avatar
  • 187
4 votes
3 answers
111 views

How can I construct an equivalence relation in the form of a 0-1 matrix from a set partition?

I have a partition of a set {1, 2, ..., n}. I would like to construct the equivalence relation that corresponds to the set partition in the form of an $n \times n$ ...
Geoffrey Critzer's user avatar
1 vote
0 answers
68 views

Sum of disjoint product of sets [closed]

If we have the following sets and we need to apply the Sum of disjoint product property to them, as in the following example: Take: $$P_1=\{x_1 x_4\}$$ $$P_2=\{x_2 x_5\}$$ $$P_3=\{x_1 x_3 x_5\}$$ <...
Emad kareem's user avatar
7 votes
4 answers
504 views

Optimal Solution for OddsBeforeEvens Wolfram Challenge

Odds before Evens Given a list of integers, rearrange them so that all of the odd integers appear before all of the even integers, without otherwise changing the order. An obvious solution is ...
Navvye's user avatar
  • 151
3 votes
1 answer
80 views

Quickly processing long lists using SequencePosition

Overview SequencePosition does exactly what I need; however, it seems to be very slow for long lists. Is there an input option that would allow it to process faster? Or, perhaps an alternative ...
user6546's user avatar
  • 1,059
1 vote
0 answers
80 views

How to efficiently calculate matrix operations when the elements are defined as functions?

I'm trying to calculate the one-body density matrix of a system of particles as described in this article, given in equations 14 and 15. Here, is my code but it seems very slow. Is there any efficient ...
sudipta's user avatar
  • 63
7 votes
1 answer
494 views

How does this code work?

I saw this thread and upvoted many answers there. Below is the answer by kglr (not my most favorite answer there, but it looks fun). I wonder if anyone could help ...
internet's user avatar
  • 703
8 votes
5 answers
283 views

Ordering with repeats

A quick question on list ordering, how can I easily get the ordering of the list, so that, for {0, Sqrt[3], 2 Sqrt[3], Sqrt[3], 3, 2 Sqrt[3]} I get ...
sam wolfe's user avatar
  • 4,553
11 votes
6 answers
1k views

A complicated sorting problem

ClearAll["Global`*"]; list = {{c, c, c}, {b, b, b}, {a, a}, {x, x}, {d}, {e}}; I want to sort the sublists with more than one element in descending ...
eldo's user avatar
  • 61.4k
8 votes
6 answers
456 views

How to create an array from all combinations of the vector components?

Say I have vectors {a,b,c} and {w,x,y,z}. How can I get Mathematica to output an array ...
A P's user avatar
  • 83
2 votes
1 answer
88 views

General Trend of a ListLogLinearPlot

I have a data file. I must plot this using ListLogLinearPlot and identify the trend (or the mean). Below is my code for Importing the data file and plotting it. <...
user444's user avatar
  • 2,178
0 votes
0 answers
52 views

Is the output of TreeForm expected to follow the level's of an expression?

I have an expression ...
Karl Easterly's user avatar
7 votes
6 answers
541 views

How to identify intervals for each integer number

I have two lists: ...
Tugrul Temel's user avatar
  • 6,142
2 votes
4 answers
114 views

Rescaling the data points

Lets say I have the following data points, ...
a019's user avatar
  • 845
0 votes
0 answers
44 views

Recall a position in a list

I'm working with a data set that is coded as: {xdata,ydata,zdata} Since the data is collected in a serpentine pattern it spits out the data as: ...
Alex Wong's user avatar
4 votes
6 answers
378 views

How do I reshape a list of this form?

I apologize if this is an already answered question, but I haven't been able to find it. I have a long list that has this form: ...
juv95's user avatar
  • 351
2 votes
1 answer
58 views

Handling different kind of indices in single tensor equation

I want to solve the following differential equation, $$\partial_a (\sqrt{h} \, h^{a b} \partial_b X^{i}) = 0$$ where $$X^i \equiv \{X^1(\sigma^1, \sigma^2), X^2(\sigma^1, \sigma^2), X^3(\sigma^1, \...
Physics Moron's user avatar
1 vote
4 answers
119 views

What is wrong when I use Length[{a, b, c}] == 3 in this code? [closed]

I want to creat the triples (a,b,c) so that Length[{a, b, c}] == 3, I tried ...
Thuy Nguyen's user avatar
1 vote
1 answer
39 views

How to check a group of solutions of partial differential equations?

There is the partial differential equations, $$ \left.\left\{\begin{array}{c}u_t-3qu^2u_x+\frac{3}{2}q(uv)_x-\frac{1}{4}qu_{xxx}=0,\\v_t+\frac{3}{2}qvv_x-3q(u^2v)_x+3qu_xu_{xx}+\frac{3}{2}quu_{xxx}-\...
godspeed's user avatar
4 votes
3 answers
631 views

Concise version of MATLAB code

Please see this MATLAB code: k=0:8; wk=2 * pi * k/17; ak=double(wk<0.5*pi) It generates ak with such a simple expression. To ...
metroidman's user avatar
4 votes
8 answers
381 views

Joining two lists with Transpose and with an offset

I have two lists of the same length n. For the case of n=5, these would be: ...
Karl Easterly's user avatar
5 votes
3 answers
118 views

How can I select the function and its derivative with the smallest or largest index from a list of function and function derivatives?

I have a list of functions and their derivatives. How can I select the function and its derivative with the smallest or largest index, provided that both the function and its derivative are in the ...
xinxin guo's user avatar
  • 1,177
0 votes
1 answer
101 views

Bin edges from BinCounts

I'm working with a set of data binning values. I'm using bincount and binlists to find bins that meet a certain criteria and then testing a list to see which are within one of those bins. This list of ...
kernel density's user avatar
3 votes
2 answers
144 views

How to find repeating elements in the following grid?

Consider the following table: ...
John Taylor's user avatar
  • 5,387
2 votes
5 answers
353 views

How can I remove the elements containing False in this list?

I have a list: ...
Thuy Nguyen's user avatar
4 votes
3 answers
220 views

How do I recurrently process irregular lists until they are empty?

I want to solve the following task: I have two sorted lists A and B. Let's say A={0, 1, 8, 10, 16, 17, 24, 32, 33, 34, 40, 48} and ...
tku's user avatar
  • 41
0 votes
0 answers
45 views

Removing a set of original assumptions from the result of Reduce

I am having trouble using set operations when applying them to lists which cme from the Reduce function. As an example, here is a list of assumptions and an expression for which I would like to know ...
sg1234's user avatar
  • 289
7 votes
5 answers
242 views

How to keep specific rows of a matrix based on their second element

Suppose I have the following list: list1 = {{a, 1, c, v, f}, {m, 2, s, f, a}, {s, 2, d, f, g}, {k, 3, g, f, a}, {l, 2, h, j, k}, {b, 1, n, m, d}} I need to ...
Delaram Nematollahi's user avatar
1 vote
2 answers
43 views

How can I select the positive roots in a list calculated with NSolve?

I've used NSolve to determine the roots of a nonlinear function. There are both positive and negative roots, and I only need the positive ones. I've tried using: <...
agaminon's user avatar
  • 113
0 votes
0 answers
63 views

How can a program be configured for these steps?

Is it possible to create a program that implements sequential mathematical steps... in order to be circulated to more than one selected set? Step 1: For the following sets: $$S_1=\{x_1,x_2,x_3\},S_2=\{...
Emad kareem's user avatar
5 votes
5 answers
304 views

Selecting a list of strings associated with a long list of strings

I have two lists of strings: ...
Tugrul Temel's user avatar
  • 6,142
3 votes
1 answer
168 views

What is wrong with this code to convert all elements of a list to a LaTeX file?

I have a list that I need to convert to LaTeX: ...
minhthien_2016's user avatar
1 vote
0 answers
61 views

What is another way to write this equations in this list?

I have mylist: mylist = {{6, 7, 6, 2}, {7, 9, 7, 3}}; Here are two ways that I write equations from mylist: ...
Thuy Nguyen's user avatar
5 votes
2 answers
134 views

Nested associations - flatten and unflatten

Assume I have ass = <|"A" -> 1, "B" -> <|"B1" -> 2, "B2" -> 3|>|> I can flatten it to ...
Stefan Gillessen's user avatar
6 votes
6 answers
408 views

Avoiding (numbering) duplicate keys

...
eldo's user avatar
  • 61.4k
2 votes
3 answers
210 views

Selecting triangle coordinates with all-integer centroids

Following is a list containing coordinates of triangles in 3D space: ...
John Paul Peter's user avatar
4 votes
2 answers
119 views

Assign values from a list to a multivariable function that also has other arguments

I am new to Mathematica's way of programming. I have a multivariable function, part of whose values are available as a list, and the remaining in another list. To illustrate, I will present my problem ...
haricash's user avatar
5 votes
5 answers
451 views

How can I select element of a list containing (a,b) where both a and b ara rational numbers and not integers?

I have a list of equations and I solve them ...
Thuy Nguyen's user avatar
2 votes
2 answers
227 views

How can I select real elements that not an integer and rational numbers?

I have a list list = {2, -1, 3/5, (Sqrt[2] + 1)/3, Pi} How can I select from the list real elements that not integer and rational? That's mean, how can I get ...
minhthien_2016's user avatar
1 vote
0 answers
62 views

Why is SequencePosition or SequenceCases so slow on large lists?

I observed that SequencePosition or Sequence Cases on a list of around 60'000 digits is so slow that I had to sort out to string pattern matching. Is this normal behavior or should Wolfram have a look ...
markilux's user avatar
  • 121
3 votes
2 answers
168 views

Find non-descending sequences of list pairs

...
eldo's user avatar
  • 61.4k
1 vote
0 answers
62 views

Export data vertically

I have data that I want to export to a text file. ...
Alyasaa Jasim's user avatar
5 votes
3 answers
213 views

Extraction of sublists containing certain sequence pairs

list = {{a, b, c, d, a}, {e, f, a, b, c, d}, {a, b, p, q, c, d, g, h}, {c, d, p, q, a, b}, {a, c, b, d}}; I want to filter sublists of ...
eldo's user avatar
  • 61.4k
1 vote
0 answers
98 views

Transpose Subdivided and Imported Data

I am trying to transpose two data sets for ListLinePlot. Set 1 is imported from an Excel file, and the second set is created by ...
User's user avatar
  • 11
3 votes
1 answer
82 views

Extracting sub data from large one [duplicate]

LargData = Table[{i, 2 i, 3 i}, {i, 10000000}]; // AbsoluteTiming {0.450277, Null} I want to extract specific columns from the data above but it takes ...
MMA13's user avatar
  • 4,554

1
2 3 4 5
190