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
2
votes
1answer
34 views

Filtering solutions using the Select function [closed]

I have a certain code that output in the following format: {{a1,b1},{a2,b2},{a3,b3},...,{an,bn}} Where $a_1$ and $b_1$ etc are numbers. Now I want to filter ...
1
vote
1answer
78 views

Question about the test format applied in a for loop

I have an issue with the following code. I am trying to remove the points which have a distance less than 2mm relative to each other starting with a specified point ...
9
votes
2answers
452 views

Evenly spaced Tick marks for Primes

I'm trying to have the integers evenly spaced on the x axis of a ListPlot, and the prime numbers evenly spaced on the y axis. ...
5
votes
2answers
121 views

Grouping list elements according to a condition

I have a list of "calls and responses", which are pairs of a message and then either a $0$, for a call, or a $1$, for a response. There is some amount of calls, and some amount, potentially unequal, ...
0
votes
1answer
83 views

correct use of the command FindInstance

I have tried to solve this system for numbers that go from 1 to 10 non-repeated integers, this occurs to me ...
0
votes
0answers
57 views

Resorting nested list A according to nested list B

How can sort nested list according to each other? e.g. I have the following list: ...
3
votes
2answers
66 views

Random Sample from Very Large Table

I'm currently trying to create some test data to check a numerical implementation against Mathematica's implementation of some functions. In order to do this, I've been generating a broad range of ...
3
votes
1answer
26 views

Removing elements from nested list [duplicate]

I would like to remove the element of A1 from the list B1: How I can do that? Thank you! A1= {{5, 6}, {4, 5}, {5, 4}} ...
4
votes
4answers
180 views

Dropping some row from a Table with If condition [closed]

I have to drop the rows of a table only when the element in the first coloumn of the row satisfies multiple condition. The table: ...
0
votes
0answers
35 views

Appending a list which was created with ToExpression

I would like to create many different lists by changing one part of the list name with a variable defined as a string, then creating a name for that list using ToExpression[]. ...
2
votes
1answer
49 views

How to obtain Detele

From a={{6, 4}, {8, 1}, {11, 3}} How to obtain {{6, 8, 11}, {6, 11}, {6,11}, {6}} or ...
2
votes
1answer
40 views

Select coprimes from list of pairs

Given t2 = {{1, 5}, {2, 1}, {2, 2}, {2, 3}, {2, 4}, {2, 5}, {3, 1}, {3, 2}, {3, 3}}; I can get coprime pairs by ...
4
votes
1answer
59 views

How can the missing time series values be filled?

Though there appears to be a similar question, it does not sate this use-case... I present below the MWE: I have a date-list, here it is just a linear series of numbers, but the real use-case is that ...
6
votes
1answer
107 views

How to group together numbers in a list by the value of their tens digit?

The line Table[Prime[n],{n,1000}] produces the list of first 1000 primes. Given this list how can the values be grouped by the values of their tens digit? i.e. how ...
2
votes
1answer
34 views

Quotation marks inside a list [closed]

I want to place quotations for every element in a list. I am trying this col = Table["\"" i "\"", {i, 0, 5}]; and I am getting ...
0
votes
0answers
32 views

UI building, how to input an array of number in the Manipulate function?

I'm trying to build a simple financial app with Mathematica, i'm having problems with UI building (nothing fancy, it's just an hobby). Here is the code. The problem is with the Manipulate function, i ...
2
votes
1answer
31 views

Selecting specific element from a list of lists based on values of another list

I have a list of pairs in which every pair correspond to a edge in a network (or graph). This list in a .txt file (available here https://drive.google.com/file/d/1g-1l3__IxJ8qe_wtM4_0TYuklwoH_Rqa/view?...
5
votes
2answers
58 views

ArrayPad unexpected changing of order

If I pad an array with two columns on the left the order of the columns is reversed depending on the length of the row of the padded array. I don't think this is normal, but if it is, what is the ...
5
votes
3answers
83 views

Conditional column extraction

Let $A$ be the following matrix A = {{1, 0, 9}, {5, 0, 6}, {4, 1, 9}, {7, 0, 11}, {8, 1, 2}} and let $B$ be the matrix that comes from $A$ with ...
1
vote
0answers
24 views

How to define more general boundary conditions for ConvolutionLayer?

In Mathematica 12, I only see the option to define "PaddingSize" for a ConvolutionLayer in order to get Dirichlet boundary ...
7
votes
4answers
270 views

Why AssociateTo does not work when Association is inside a list?

V 12.1 on windows 10. I am still learning how to use Associations. This is very strange. I wanted to change field in association using AssociateTo. When the ...
1
vote
1answer
38 views

ReplaceAll with pattern matching not working with list of lists

Abstract This is just a learning exercise for me. I am trying to create a function that will take a list of vectors, multiply them by a constant if constant is given, and then add all vectors. If we ...
1
vote
2answers
38 views

How do you loop a summation while taking values from list?

I have a list given as: d={{{1,1,1},{10,10,10}},{{70,70,70},{51,51,51},{97,97,97}},{{7,7,7}}} Each number in the list represents a potential "W" value for the ...
1
vote
0answers
56 views

What is the correct syntax for performing a summation using numbers from a list? [closed]

I have the following lines of code: l={1,2,3,4,5} n=5 Summation= n l Total[Summation] I would like to perform the same thing above, but in a more elegant ...
2
votes
2answers
74 views

How do you delete sublists of a desired permutation?

I have a list given as: d = {{{A1,A2,T3}, {A4,T1,A2}, {T5,A1,A3}}, {{T1,T2,T3}, {A5,A1,A2},{A1,A2,T3}}} I'm trying to delete sublists of the type: ...
4
votes
3answers
150 views

How do you apply “Pick” to multiple sublists?

I have the following list: lis1={{{A3,T3},{A3,T4}},{{A3,T3}},{{A3,T3},{A4,T4},{A3,T1}}} Which is also accompanied by an ...
0
votes
0answers
38 views

Plot inside Streamplot [duplicate]

I am looking to include plots in the $x,y$ plane that represent the lines that the fixed points of a dynamical system follow as the variable $l$ is varied. In doing this, I am trying to represent ...
1
vote
1answer
35 views

Labeling outputs of a function inductively

Suppose I have two lists labeled by the string "0" and "1" respectively, and two functions $f$ and $g$ which takes as input these lists. Is there a way that I can inductively label the outputs of ...
1
vote
3answers
59 views

Can you map an AssociationThread of multiple sublists?

I have two lists that look like this: d={{1,1,3,5,7,2},{1,1,3,5,6,7,2}} dd={{A1,A1,A3,A5,A7,A2},{A1,A1,A3,A5,A6,A7,A2}} If I use ...
6
votes
2answers
306 views

Fast multiplication of high dimensional matrix

I am very new to Mathematica. I am dealing with the multiplication of matrix as the following code ...
6
votes
2answers
151 views

How do I flatten sublists while maintaining a separation between preexisting sublists?

I have a list that looks like: z={{{a,b},{b,c},{c,d},{d,e}},{{b,c},{d,e},{w,e}}} How would I create a list that looks like: ...
11
votes
7answers
1k views

Find if there are consecutive 1s in a binary representation of a number

Given a list of numbers in decimal form, what is the most efficient way to determine if there are any consecutive 1s in the binary forms of those numbers? My solution so far: ...
1
vote
3answers
39 views

Converting a dataset to nominal data

Im trying to covert a list of data to nominal data. Here is the data. ...
2
votes
2answers
47 views

Counting inside Sublists [closed]

I have the following problem. Given n_ for a square matrix. n=3 Makes: lst = {{1,2,3},{4,5,6},{7,8,9}} Can this be done with Map[? I can do it easily with Table. ...
5
votes
1answer
115 views

Identify flipped data

Edit I'll try to reformulate my problem to make it more clear. Consider association with elements of the form {x,y} -> {f(x,y),g(x,y),...}, where keys are ...
0
votes
0answers
55 views

Evaluate parameters before function uses them

I want to construct a power series: LP[s_] := With[{x = 1, R = 10, n = 1}, Sum[cc[i + n, n, x, R] s^i, {i, 0, 20}]] but it kinda takes a long time to compute the ...
4
votes
2answers
59 views

applying compound function on parts of list

I have list t1={{1, 2}, {2, 5}, {3, 10}, {4, 17}, {5, 28}, {6, 41}, {7, 58}} and want to substitute the second part with the biggest prime factor in it, giving ...
1
vote
2answers
36 views

Conditionally extracting data from long lists

I need to make a fit on a small part of my data list. To do so I need to extract data setting a condition. Example: From the list below I would like to create a new list that contains only data whose ...
1
vote
2answers
49 views

How do I pull out sublists from a list under a given condition?

is there an easy way to pull sublists out of a "master list" based upon certain conditions? Let's say I have a list: list1={{{1a,1b},{1a,1c},{1a,1a},{1y,1y}}} ...
2
votes
3answers
112 views

Turning numbers embedded in deeply nested lists into strings [closed]

This must have a simple answer, but I cannot think of it. I want to take the numbers in a list such as: {1,{2,{{3,4},{5,6}},7,8} into strings. ToString will turn the whole list into a string. ...
5
votes
2answers
84 views

Removing specific sublists

I have a program that generates a list of specific 3-tuples of integers. A typical output is as follows: ...
1
vote
0answers
34 views

Remove braces from AppendTo output

If I have the following inside a loop: tts={}; AppendTo[tts, p] where p is just a number at each iteration so that in the first iteration I get: ...
1
vote
0answers
29 views

Get second position elements given a criteria [closed]

I know this is a very simple question but I am fairly new in Mathematica. If I have this list: ...
0
votes
2answers
52 views

ListPlot and comparisons between lists

The problem is a bit tricky, I will try to be as clear as possible. I have several lists (let's call them x, y, z and k), all of the same length, and where the i-th value of each list corresponds to a ...
6
votes
4answers
174 views

Shifting and adding the columns of two lists

Let's say that I have this list a={{-2, 1}, {-1, 2}, {0, 1}, {1, 0}, {2, 0}} and I'd like to change the value of the elements in the column to obtain something ...
2
votes
1answer
44 views

Summation over specific tuples

I would like to write a function that would, given a positive integer $n$, compute the following: $S_n = \sum_{(x,y,z)} a_{(x,y,z)} f(x,y,z)$, where the sum runs over all tuples $(x,y,z)$ such that $...
1
vote
1answer
31 views

Where To Start; Numbered Triangle

I am working on a square matrix. Cell (1,1) starts at 1, and each following 2, then 3, .., working x to y order. Plus, each cell is computed after this, to Sum of Squares minus Sum of each cell. Sorry,...
3
votes
2answers
88 views

Adding fractions from subsets of variables

...
4
votes
2answers
90 views

Determine whether a list is a reordering of another

For some context: I have a function Prod[a___,state] which represents a list a___ of quantum mechanical operators acting on a state. After manipulating the elements ...
3
votes
1answer
57 views

Producing “binary” associated lists

This is a problem for which there must be an elegant and efficient solution which eludes me. The problem is best described with an example. Suppose you have the list $v$ of numbers from 1 to 10 in ...