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
1answer
24 views

Display lists in a table form

I would like to display the lists in a table as in the image. How can I make it work? ...
0
votes
1answer
39 views

AddTo operation to random element of a list yields unexpected results

I have a list of numbers. I want to randomly select one of those, with a probability proportional to its value, and increment it by one. I tried this simple one-liner ...
0
votes
1answer
32 views

Extract coefficients and terms in polynomial expansion [closed]

I have a polynomial in $a$ and $b$: $$(Aa^2 + Bb^2 + Ca + Db + E)^m$$ How can I construct a table of coefficients corresponding to all different products $a^i b^j$ in the expansion for a defined $m$, ...
0
votes
0answers
26 views

Mathematica CSV values

I wanted just to add constant to each value. i. e. data = Import["/Users/paul/Desktop/rtm1.csv", "CSV"] And I get ...
8
votes
3answers
636 views

Is there a neat code to swap elements of a list?

I want to swap the list to make a new list as follows. The code works but I'm wondering if there is a neat code, or an elegant way to do this. ...
1
vote
1answer
30 views

Remove elements from a tuple with conditions

I have a tuple mytup. Assume two arbitrary elements from the tuples are {a1, a2, a3, a4, a5, a6, a7, a8, a9} and ...
0
votes
1answer
32 views

How to group terms in an expression according to the powers of their variables?

Let us consider the following non-linear 2nd-order ODE: \begin{equation} \scriptsize{ 2 \zeta q_1'(\tau )+q_1''(\tau )+q_1(\tau ){}^3 \left(\theta +\sigma \left(-\epsilon -\frac{3}{2}\right)\right)+...
0
votes
0answers
50 views

Why is the label is put inside parentheses No (1)? [closed]

I made the following plots. However, why is the label is put inside parentheses like that, for example No (1)? In the code, I don't see anywhere that could happen. ...
0
votes
1answer
24 views

Recursive addition of vector list to last elements of vector lists

This question refers to an extension of Add list of vectors to list of vectors recursively . I tried hard to complete the problem but now I got stuck. I have vectors ...
2
votes
4answers
132 views

For all x in {1,2,3}, x is bigger than 4

I am new to ForAll or Exists command. Resolve[ForAll[x, Element[x, Reals], x > 4]] gives ...
1
vote
1answer
31 views

Import list to excel

If I have several lists such as: ...
1
vote
1answer
32 views

Joining each element of second tuples to the end of each element of the first tuples

How can I generate a new tuples by joining each element of tup3 to tup1? For example joining {0,1,1,1,0,-1} from tup1 and {d,0,1} from tup3 to generate {0,1,1,1,0,-1,d,0,1} ...
1
vote
0answers
72 views

Symbolic add of 32Bit Registers

I would like to perform multiple 32bit word register additions (mod 32 add. with variables of Boolean type shuffled with symbolic type). For this task I implemented a ripple adder function: ...
2
votes
1answer
48 views

Build a list from events

Say I have a list of elements of type {name, direction, time} where direction can be in or <...
4
votes
2answers
87 views

Select elements of a list

Suppose we have the following data list ...
1
vote
1answer
78 views

How to add a vector list to a multiple dimension list of vectors

This problem is related to Add a vector to a list of vectors. Given: ...
1
vote
0answers
22 views

Fastest way to do repeated subsample/Intersection calls over large set of vectors

In this answer I found I needed to calculate a bunch of intersections of subsets of vectors, like ...
1
vote
1answer
28 views

Extracting Y-coordinates for list1, for X-coordinates of list2 while their lengths are not same

I have two lists list1={{1,2},{3,4},{5,6},{7,8},{9,10},{11,12}}; list2={{1.3,12},{3.2,14},{5.4,15},{7.1,16},{9.5,17},{11.6,18},{12.7,19.7}}; X coordinates from ...
2
votes
4answers
170 views

Adding more data points to the list by averaging parent data points

I have a list "{{x1,y1},{x2,y2},{x3,y3},{x4,y4},{x5,y5},....,{xn,yn}}" and now want to modify it as below ...
4
votes
1answer
71 views

Create a new list from given data

Let us consider the following type of data list ...
4
votes
2answers
152 views

Changing the repeated number on a list

How do I change the repeated numbers in a list randomly such that the numbers are no longer repetitive? I have my list to be A={{3, 1}, {4, 1, 2}, {1, 4, 5}}. Here ...
1
vote
2answers
39 views

For loop over several arguments with different length each

I have a set of text files named in indexed way d1, d2, d3, d4, d5, d6, d7, d8, d9. I want to read them by Mathematica and export them back with other index names N(s1f1+s1f1), N(s1f1+s2f2), N(s1f1+...
0
votes
0answers
43 views

Partitioning in the given way [closed]

Assume that we have some table tab = Flatten[Table[{x,y,z},{x,1,2,0.1},{y,2,5,0.1},{z,10,100,10}],{1,2,3}]; Is it possible to restore a table ...
-2
votes
4answers
248 views

Extrude 3D list with thickness n

I have a 3 dimensional list of points which i would like to extrude in z coordinate with thickness n, i.e. z_{i} -> z_{i}+n for all points in z. There is a similar question concerning 2d list where ...
4
votes
2answers
103 views

bind specific 'Slots' to specific 'Map'

Is it possible to construct a pure function using multiple slots, with the following concept :       Binding   specific slot    to    specific apply or map For example : In this example, To ...
3
votes
1answer
70 views

How to arrange two tables in the following way?

Consider two tables: ...
2
votes
0answers
27 views

Convolution for large arrays went wrong [closed]

I am trying to use ListConvolve[a, b, {1, -1}, 0] for large arrays a and b (1024 length) to ...
1
vote
1answer
48 views

How to flatten the given table?

Consider a table Table1 = Flatten[Table[{x, y, {f1[x,y],f2[x,y],f3[x,y]}}, {x, 1, 2, 0.001}, {y, 2, 3, 0.001}],{1,2}]; Could you please tell me whether it is ...
6
votes
1answer
74 views

Splitting a set of integers over a set of bins

I have a problem that feels like it should be simple but I'm just drawing a blank on. I've got a set of integers, e.g. ...
3
votes
1answer
49 views

identify sequence in a list

I have a large list of real numbers, that vary between a maximum and a minimum. For the sake of an example: megalist=RandomReal[{-5, 5}, 10^4]. Now, I have a much ...
2
votes
2answers
57 views

List X is a starter of List Y

For lists X and Y, let's define a term 'X is a starter of Y' to be 'there exist a list Z such that Y = Join[X,Z]'. Until now I've used following code for 'X is a starter of Y' ...
0
votes
1answer
34 views

Add list of vectors to list of vectors recursively

This question relates to Add a vector to a list of vectors whereas here I want to add list of vectors to list of vectors recursively. Given: ...
1
vote
1answer
24 views

Replacement rule from list to powers

I would like to write a replacement rule that gives all the possible products of traces for a given length. For example, all the possible partitions of length 3 can ...
5
votes
3answers
237 views

How can I reorder levels of a list in a performant way?

I have the following problem and I am not sure how to speed it up: I construct a list element by element like so: a[[i]]=Table[some_function[j,k],{j,1,3},{k,1,6}] ...
1
vote
1answer
37 views

Apply function using level

The following use of Level is documented, without any example. Let's try some simple codes : ...
1
vote
1answer
34 views

Applying FoldList using a Function

Given p={2, 3, 5, 7, 11, 13, 17, 19} I want to get the values which can be calculated by ...
2
votes
2answers
90 views

Restrict kinds of heads when dealing with level concept

In[1] Map[(# + 7) &, {a, 3 b, {c, d}, e}, {2}] Out[1] {a, 10 (7 + b), {7 + c, 7 + d}, e} But I want feature like ListMap : ...
2
votes
1answer
28 views

Manipulating lists of rules of irregular length

After solving a function I get a list as a set of rules. ...
4
votes
3answers
235 views

Extrude two dimensional list with thickness n

I have a question concerning how to extrude a two dimensional list. There are examples in mathematica forums how to extrude but none of them (as far as i know) discussed how to do it with a list. My ...
0
votes
0answers
37 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
118 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
57 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
117 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
44 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
26 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: ...
15
votes
1answer
246 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
48 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
115 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
88 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
2 3 4 5
139