# Tagged Questions

Questions on the manipulation of List objects in Mathematica, and the functions used for these manipulations.

104 views

### Replacing Logic operator List and generate combination of variables

so I'm trying to do the following starting from a list of inequalities: ...
293 views

### The efficiency compare between Flatten[#, 1] & and Join @@ # &

Err..Often I met the situation to join lists at the first level and I used to just Flatten[#, 1] &@ them. However, I found(when glance over the mathematica.stackexchange.com) someone else prefer ...
23 views

### Manipulating nested matrices columnwise [duplicate]

I have a project that requires analyzing large volumes of excel sheets at the same time. I have been having trouble figuring out how to index the imported files and manipulating them. The way I am ...
180 views

### Duplicate mapped elements in Riffle

What is the best way to do this? in: {a, b, c} {d, {e, f}, g} out: {{a, d}, {b, e}, {b, f}, {c, g}} ...
319 views

### What does IndexBy do and how exactly does it work?

I just saw the function IndexBy in the autocomplete suggestions and I was curious to know exactly how it works. Unfortunately, there's no trace of it in the ...
442 views

### How to randomly select subsets

I have a list of around 300 elements. I want to sample subsets of length 25 such that my samples are all distinct. My first inclination was to use something like ...
130 views

### Output function control and manipulation for efficient computation [closed]

I have taken note of a similar post related to modifying function parameters. I tried to adapt Kuba's solution to this post but I can't get it to work. I will illustrate my problem using a similar ...
592 views

### Plot a table of lists

I want to make a point plot of a table with lists in it. Assume I have data like this: data={{1,2,3,4},{5,6},{1,5},{2,4}}; and now I want to make a point plot ...
57 views

### Table results within loops

I have the following code. ...
222 views

### Iterating over a 2D list [closed]

I want to collect the result of a function in a data structure. In java the loop looks like the following code: ...
62 views

### Compute the evolution of several quanties from a data file

This question is somehow a part II of this: Part I. Here comes a small data sample as a minimal working example: ...
266 views

### How to select elements from a list by condition?

Considering I have a list: F = {f1, f2, f3, f4} I want to perform exponent on the list F = Power[#, 2]& /@ F Now I ...
210 views

### Pure function, one slot refers to List-position

I used all my google-fu trying to find how to make this work; read the docs as well. What have I missed? I feel sure this can't be a new question, but I can't find anything Here is is: ...
1k views

### Dramatic speed difference of code on Matlab and Mathematica

Background: I was trying to convert a Matlab code (fluid simulation, SPH method) into a Mathematica one, but the speed difference is huge. Matlab code: ...
66 views

### List manipulations with ; and ;; [closed]

I have the following list: L = {{a1,a2,a3,a4},{b1,b2,b3,b4},{c1,c2,c3,c4}} By using just the ; or ...
484 views

### Making table and plotting results of NDSolve problem

I am trying to solve two equation to find /[Phi][x] and plot h vs. /[Phi][x] for different values of L.I tried by writing as: ...
66 views

### Code optimization, Pad missing keys and Total part of values [closed]

Code optimization, Pad missing keys and Total part of values ...
73 views

### Encoding variables

I'm trying to fit a Logistic Model using LogitModelFit in Mathematica. The data I'm using contain qualitative variables that I have to encode. I've searched in ...
210 views

### Functional programming approach to avoid traditional loops

I'm currently learning from the wonderful post: Where can I find examples of good Mathematica programming practice? And i'm correcting my habits using Nest/Map/Thread instead of loops. The problem ...
268 views

### Appending elements to a list in parallel table

Is there any way to store values in a list that is being computed in parallel? For example, if ParallelTable is computing some ...
135 views

### Contract two lists

Suppose I have two lists of the equal length in the form powers= {{rho th},{mu},{beta},{nu},{r},{}} ...
25 views

### Iterating a model with 2nd order difference equations using Manipulate [duplicate]

I have a model including first and second order difference equations. It works for the case of first difference equation, which is below: ...
36 views

### Error with AppendTo [duplicate]

I am trying to write a function that builds a graph, or - better said - adds a layer of leaves to a pre-existing graph. Basically, I hand to the function three lists. ...
27 views

### Extracting subscript and superscript [duplicate]

I have an expression in the form Power[Subscript[g,a],mu] and I need to extract "a" and "mu" from this expression. It should be very simple but I could not find ...
145 views

### Finding column-wise ranks of values in a multidimensional list

I often have to find ranks of values in a list. However, Mathematica does not have built-in functions for that, or may be I'm just not aware of them. I can easily find ranks of a row/column vector. ...
188 views

### LinearModelFit[] of simulated data

I'm trying to simulate Hooke's law, f = k * x, so I generate data with the code: ...
118 views

### Importing, sorting and exporting lists

I have several TSV lists (.txt) of something like 2000*2000 numerics (e.g. 1.8645) to import ...
140 views

### Autocorrelation of 3D Points

I'm trying to compute the autocorrelation of a list of points $(x,y,z)$ in 3D. Can the CorrelationFunction or maybe ListCorrelate...
85 views

### Convex Combinations of List Elements

Let's say I have two lists $L_1=\{a_1,...,a_5\}$ and $L_2=\{b_1,...,b_10\}$. Is there an easy way to make new lists from convex combinations of these two lists' entries? Let me be more specific: 1 ...
589 views

### Converting two lists into a list of tuples [duplicate]

I wonder how I can turn the list $\{a_1,...,a_n\}$ into the new list $\{(a_1,1),...,(a_n,n)\}$, i.e $a_k \mapsto (a_k,k)$, how do I do that? I figured the function Tuples might work, but it just ...
58 views

### Delete String sub list

I have a list with several sub lists containing either strings or integers. I'd like to delete all list with strings. The following list ...
160 views

### Finding pairs where the intersection of them is empty set from a nested list

It would be better to give an example first. Suppose I have a nested list of the form list = {{ 1,2,3,6}, { 3,6,10,20}, { 4,7,11}, { 10,20}}; where each element ...
161 views

### Function like Cases/Select which also returns complement

I'm looking for a function similar to Cases or Select, but that also returns the complement of the resulting list. In other ...
151 views

### Dirichlet convolution of two lists [closed]

The Dirichlet convolution of two arithmetic functions f,g is defined by $f\ast g(n) = \sum\limits_{d|n} f(d)\ast g(n/d)$ How can I get the Dirichlet convolution of two lists? For example: Input: {1,...
57 views

### Using NestList instead of Do [duplicate]

How can I express the following code using NestList: ...
141 views

### How to define a list of symbols as a list of functions?

I have a list in Mathematica for example P={1+t,1+t+t^2,1+t+t^3}; My question is, how I can define each element of this list be a function of ...
109 views

### Exclude elements from mapping

I have had this problem way too often and still have not found a solution, yet. One acually used code is:` ...
94 views

### Cannot use Part in Pure Function [duplicate]

I need to select some lists in the nested list of form of {{1,2,3},{2,3,4}}. I have used Select to complete my work. But when I tried Position, it doesn't work. For example, ...
748 views

### Calculating weird numbers

A weird number is a number such that the sum of the proper divisors (divisors including 1 but not itself) of the number is greater than the number, but no subset of these divisors sums to to ...
69 views

### How to edit a list according to the other list? [duplicate]

Gday guys. This problem troubles me, and I hope you can help me solve it. Say I have two random lists L1={{2},{5},{1},{0},{4},{7},{8}} L2={2,5,1,0,4,7,8} and ...
50 views

### Mathematica defines a function as list

This might be a very silly question but i'm defining a function as: \[Chi][AR_] := ((AR^(2) - 1)/(AR^(2) + 1)); which is clearly a scalar function of AR; however ...
126 views

### position of rows (or columns) whose elements all satisfy a condition

How do I determine the position of rows whose entries all satisfy some condition (e.g., all elements of the row are positive)? I've found out how to use Select to ...
65 views

### Transform List from {a,a,b,b,b,c} to {{a,2},{b,3},{c,1}} [closed]

The title pretty much says it. I want to map over the solutions returned by Solve but want to avoid calculating the same thing over and over again. e.g. ...
142 views

### Creating an autokey cipher function

Can someone help me with putting what I can say in words into code. I want to create autokey encrypt and decrypt functions (just wanting help encrypting and then can figure out decrypting). Everything ...
90 views

### How to list indices of list elements that meet a condition? [closed]

Is there a tidy way to create a list of the indices of elements of a list that meet specified conditions? This method gets the job done, but it's clumsy and not conducive to nesting: ...
232 views

### How to check whether elements of a list meet a condition without generating the whole list first?

I have to find the number of elements satisfying a given condition from the set: Tuples[Tuples[Tuples[{0,1},n],n],m] The condition for $n=3,m=3$ is: ...
232 views

### Sort two lists at the same time, based on another

I am new to using Mathematica and I can not find a solution to what I am wanting to do. I want to take a list such as: x = {1,2,3,4,5,6,7,8} and a second list (...
327 views

### Counting subsequences (i.e., patterns) within a list?

I would like to count the number of subsequences in list. Say I have data given by: data = {1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 1}; I would like to count the number ...