Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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

Element-wise maximum of two matrices

I am trying to compare two identically-shaped matrices and select the minimum of the two. This is an extension of a past question: Element-wise min of two lists, except I have three nested lists. <...
1
vote
1answer
29 views

Part Assignment of variables with argument

I do not really understand why this: a = {1, 2, 3}; a[[1]] = 3; a {3,2,3} works as desired, but this does not: ...
0
votes
1answer
32 views

Importing a 3 dimensional list

I have a code that is generating some numerical data in the form of a list of trajectories. Each trajectory itself is a list of 2D coordinates. Each coord. is a list of 2 numbers.(see example data ...
2
votes
2answers
67 views

Create a list of the first 100 deficient numbers

For the purposes of the assignment, I need these values in a table. We have so far only used for/while loops to check the deficiency or abundance of certain types of numbers. I initially tried using a ...
1
vote
0answers
34 views

Transpose two lists with rightarrow and commas [on hold]

I need to transpose the two following lists: data0 = {99.52267, 93.78726, 99.67644, 99.85036}; error0 = {0.21152, 0.37626, 0.16309, 0.10167}; Into ...
2
votes
1answer
33 views

Interpolating and subtracting two sets of data

I have a data set "data9k" with x varying from 0 to 365, and another data "data0" set with x varying from 0 to 365. But the x values for both data sets are not same but similar. I want to subtract the ...
2
votes
1answer
53 views

How can a set of rules be applied to edit strings within a list of lists while maintaining list structure?

In attempting to read a webpage ("https://www.house.gov/representatives#by-name") I have managed to import a table using ...
2
votes
1answer
35 views

How to Mathematica applied discrete Fourier transform to matrix?

I am new user of Mathematica, sorry if my question odd. I not understanding, how to Mathematica apply the discrete Fourier transform for matrix: ...
0
votes
1answer
77 views

Why is lisa[i_, j_] :> Nothing un-evaluated?

Anyone know how to correct it with minor change? Input...
3
votes
4answers
201 views

How to select pairs in a list of pairs where the second pair element is within a specified range? [closed]

I have a list like the following list of pairs: ...
2
votes
1answer
32 views

Removing all sublists containing any arbitrary string as one or more of its list component

so, basically I have a list of sublists of varying length. For example, ...
0
votes
1answer
28 views

assigning integers to inner lists

Consider a asymmetric list which has been obtained from a NSolve command ...
0
votes
1answer
25 views

Deleting numbers from a list based on another longer list [closed]

I would like to delete all elements of a list that are equalled to any element found in a bigger list. For example, if I had A = {1,2,3,4,5} and B = {2,4,6,8,9,12} I would like to get C = {1,3,5} ...
5
votes
4answers
840 views

Flatten an array

I have obtained an array of results as follows ...
5
votes
7answers
1k views

Make a list of Fibonacci numbers less than 1000, whose index is in the form 3m+1. Verify that all these numbers are odd

I've been working on this for far too long with unsatisfactory results. And after losing all my hours of work around 4am thanks to a glitch in the program itself, I'm at my wit's end. It was ...
3
votes
1answer
44 views

How does the Fourier transform take its input?

I'm using the Fourier command and I'm wondering how does it take its imput. I know that it takes a list of numbers representing a function of time and it gives back a list of numbers representing a ...
4
votes
4answers
95 views

How to transform an UpperDiagonalMatrix into a symmetric matrix in Mathematica 5.2?

I have an UpperDiagonalMatrix as the following, how to transform it into a symmetric matrix in Mathematica 5.2? Note: don't use the command ...
2
votes
1answer
38 views

Remove elements from a list with a mask

Suppose we have a list {a, b, c} and a mask {1, 0, 1} (or {True, False, True}). And we want ...
4
votes
4answers
1k views

I wanna get a result of i/j . Like 1/3, 1/5, 1/7, 3/5, 3, 5/3… Something like that. But none of my code works [closed]

None of this works,can anyone correct this? 1st method j = {1, 3, 5, 7, 9}; i = {1, 3, 5, 7, 9}; jase[i_, j_] := i/j 2nd method ...
0
votes
0answers
25 views

Correctly Evaluating the existence of Large Solutions

I'm trying to correctly evaluate $$D(S\cap[a,b])=\lim_{n\to\infty}\frac{\left|S\cap{F_n\cap[a,b]}\right|}{\left|F_n\cap[a,b]\right|}$$ where $D$ is the density of $S\cap[a,b]$ (in $A\cap[a,b]$), $[...
2
votes
1answer
53 views

Find highest values between two different sets

I have the two following lists: ...
0
votes
1answer
24 views

At how many of these points is f(x,y) (strictly) greater than both g(x,y) and h(x,y)? and

I try too find out the solution but is not work. Please help! This what I wrote:
2
votes
0answers
34 views

Why does accessing the first element of a list yield “List” [closed]

I have a list of expressions listOfStuff = {-(b^(3/2)/Sqrt[7 \[Pi]]), b^(3/2)/Sqrt[7 \[Pi]]} When I try to access the first element of this list like so ...
5
votes
2answers
83 views

Element-wise multiplication of an array and a matrix

How can I express multiplication of an array and a matrix so that {x, y, z}*{{10, 20, 30}, {0, 1, 2}} gives ...
6
votes
6answers
550 views

How do I count the number of elements in a list which are between two determined values?

I have a long list (apprx. 10000 elements) of numbers. I want to count the number of elements between two determined vallues a and ...
7
votes
4answers
674 views

Mapping string into integers

Suppose I have the following list, l = {{"b", "c", "d"}, {"e", "b"}, {"a", "b", "d", "e"}} and further suppose I have the following association, ...
5
votes
5answers
366 views

A replacement for NextPermutation in Combinatorica

Does anyone know of a replacement for NextPermutation in Combinatorica? The problem with loading Combinatorica is that it interferes with new functionality which I ...
1
vote
0answers
71 views

If someone would want to think about the question: mathematical-optimization “Banknote”

I solved the puzzle of IBM Ponder This September 2019 by my code written with mathematica. I would like to share this code after the solution that will come as soon, and discuss it. In the meantime, ...
0
votes
1answer
84 views

Fast way to count distinct pairs of integers

I have a association list, S, whose size is about 5*10^4. I also have a function F which takes in ordered pairs of elements from S, and spits out ordered pairs of integers. There is some amount of ...
2
votes
0answers
41 views

Net layer that replicates last element

I am trying to design a neural network layer that takes in an array of dimensions n x 100, and produces an array of dimensions ...
11
votes
7answers
452 views

How can I add just the second elements in lists of pairs?

Say I have two lists of pairs: a = {{1, 2}, {3, 4}}; b = {{5, 6}, {7, 8}}; And I want to add the second element of every pair in ...
0
votes
1answer
31 views

Retrieve the independent variables from a linear replacement list

Is there a good way to convert a linear replacement list into a list of the independent variables? For example, I would like to take {n1->n3+n4, n2->n3+2n4} and get {n3,n4}, the variables that n1 and ...
5
votes
3answers
171 views

Adding elements to some sublists of unequal length

Complicated title for a simple problem: I have list a = {{1, 3, 5, 2}, {2, 6, 2}, {3, 5, 6, 1, 2}, {4, 2}} In which the first element of each sublist is ...
0
votes
0answers
27 views

Speeding my code to calculate a density which uses Folner Sequences?

I created a code which calculates $$D(S\cap[a,b])=\lim_{n\to\infty}\frac{\left|S\cap{F_n\cap[a,b]}\right|}{\left|F_n\cap[a,b]\right|}$$ where $D$ is the density of $S\cap[a,b]$ (in $A\cap[a,b]$), $[...
0
votes
0answers
26 views

Easiest way to simultaneously keep track of two values in a list

I have a bunch of functions a,b,c,... that all take in a list of images and return a list consisting of a list of transformed images, and a number (let's call it ...
0
votes
0answers
30 views

Why is my code for density using Folner Sequences giving incorrect values? [duplicate]

I am creating a code that calculates or approximates $$D(S\cap[a,b])=\lim_{n\to\infty}\frac{\left|S\cap{F_n\cap[a,b]}\right|}{\left|F_n\cap[a,b]\right|}$$ where $D$ is the density of $S\cap[a,b]$ (...
1
vote
1answer
63 views

How to pass pair of parameters in function

I am writing a function with a pair of values {x,y}, I have issues when I apply this function to list such as...
0
votes
3answers
82 views

Using StringJoin

Is there a way to use StringJoin to go from: {{abc, 0000}, {def, 1111}} To {{abc_0000},{def_1111}} I've been trying to use Map and MapThread with StringJoin but have failed.
0
votes
0answers
22 views

Approximating the density of an arbitrary set using an arbitrary Folner Sequence of its superset [duplicate]

How do we use Programming to approximate this limit where is the density of in , is the Folner Sequence of , is an interval with , and . For more information, click on this link (replace G,X,i,g ...
1
vote
2answers
45 views

How can I convert a matrix of 3d experimental data into a 3d list which can be interpolated in a f(x,y) function

I have a 3d experimental *.txt data with the form: y1 y2 y3 x1 f(x1,y1) f(x1,y2) f(x1,y3) x2 f(x2,y1) f(x2,y2) f(x2,y3) x3 f(x3,y1) f(x3,y2) f(x3,y3) I need to ...
8
votes
2answers
341 views

How to explain the strange behaviour about Function Nothing [duplicate]

There are some things wrong when i try to delete an element of a list by using function Nothing. Here is a simple example: ...
1
vote
2answers
200 views

Approximating the density of $S\cap[a,b]$ using a Folner Sequence of $A$, where $S \subseteq A$?

Edit: I redid my code but it's still not working. How do we use Mathematica to approximate $$D(S\cap[a,b])=\lim_{n\to\infty}\frac{\left|S\cap{F_n\cap[a,b]}\right|}{\left|F_n\cap[a,b]\right|}$$ ...
13
votes
6answers
621 views

Replace zeros in a list with last nonzero value

This question is closely related to the problem of zero crossings. Suppose I have a list l = {-1, -1, 0, 1, 0, 0, -1, -1, 1, 1, 1, 0, 0, 0, -1} and I want to replace the zeros with the previous ...
1
vote
2answers
31 views

Export list of numbers as one line to a text file

I have the following list: list = {1,2,3,4,5} Now I would like to export the list to a text file such that the numbers are all on one line separated by a tab: ...
4
votes
2answers
88 views

Thread a list of replacement rules into a list

I think I am missing something simple, so I apologize in advance... I have two lists {-1 - $\epsilon$ + 1/2 $\epsilon^2$ x''[0], 1 - $\epsilon$ + 1/2 $\epsilon^2$ x''[0]} and {x''[0]-> -1, x''[0]->...
1
vote
1answer
67 views

How to put the plot together?

I have a very long code which at the end, I get two plot (main energy plot and energy bar attached pictures). I need these two plots next to each other (for paper). Problem is I can not save the ...
5
votes
3answers
216 views

Number of list elements less than a given integer

I'm trying to make a function whose input is a list, and that outputs a list for which the nth element is the number of elements in the input less than n. So far, I have ...
6
votes
4answers
641 views

MaxDetect speed

What's the fastest way to find the local maxima of a 2D list? E.g. ...
4
votes
4answers
145 views

extracting sublists

I have a list consisting of DateObjects and strings: ...
1
vote
1answer
30 views

Subtracting one list from another nested list

I have a nested list and I want to subtract from that list based on elements of another list, where each element of each nest subtracts the other list. For example, getting from A and B to C A = {{...