# Tagged Questions

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

230 views

### Simpler way to repeat an execution with 2D points?

q has the coordinates of quadrilateral. I can get the output below with brute-force but I want to find a simpler solution, perhaps something like f<-q[[1;;2]]. ...
257 views

### How can I permute a multiset?

I have a multiset {1, 3, 3, 1, 2} and would like to randomly permute the classes like so: {2, 1, 1, 2, 3} or {3, 2, 2, 3, 1}, what is the simplest and most efficient way to do this? In reality the ...
592 views

### Very fast way to do a coordinate frame transform

I need a function that rotates and translates a huge amount of line segments. For example, I have a set of line segments in the form {{x0,y0,z0},{x1,y1,z1}} ...
290 views

### Creating a Nearest function programmatically

I've been trying to work out how to create a Nearest function programmatically. My goal is to produce something similar to this, a hand-assembled function: ...
509 views

### Constructing lists by applying functions to another list

Suppose f is a function of two variables: $f = f(x,y)\quad$ and $L$ is a list. Could someone help me in defining a list of the form: $D = \{f(x,y)\ |\ x \in L,\ y \in L\}$ I tried this: ...
386 views

### The gap between MapAt and ReplacePart for 2D data tables with headers

Consider a relational table derived from survey data, where each column ("001-01" ...) represents a responder and each row (...
171 views

### Behavior of Inner depends on List dimensions?

Consider the following case: ...
168 views

### splitting a list into files

Given is a list with x, y, z coordinates: {{100, 94, -1.112}, {100.05, 94, -1.112}, {100.1, 94, -0.982}, ..., {100, 94.25, -1.112}, {100.05, 94.25, -0.855}, {100.1, 94.25, -0.728}, ..., ...
473 views

### Generating Linear Extensions of a Partial Order

Given a set $S$ and a partial order $\prec$ over $S$, I'm looking for a way to "efficiently" generate a list of linear extensions of $\prec$. Suppose the partial order is given by a ...
422 views

### Creating a list of PopupMenus that dynamically update an element in a list

So as the title says I am trying to make a list where each element is determined by a users choice of an element in a PopupMenu. My first attempt: ...
459 views

### Fastest way to sum pairwise potentials

I've been writing a function to sum a pairwise potential on two lists, i.e. two charged bodies, each containing N >> 1 and ...
903 views

### MapThread over sublists of different length

I have a list which looks like this: l={{1,0,3,4},{0,2},{0,0,1,3},{1,2,0}}. Now I would like to count how many 0s the sublists contain in the first, second,... ...
2k views

### How do I split up a curve into chords of equal length?

I have a curve that is defined as f[x] and what I'm attempting to do is to divide the curve into equal straight lengths for a number of segments of my choosing that I've defined as nSeg. I've created ...
261 views

### Using the elements of a subset in a Do loop

I would like to use the elements of Subsets in a Do loop. I have: ...
392 views

### Incrementing a nested list element

I've been wanting to increment a nested list element of which I know the "coordinates". I thought of the following procedure, using Apply with Part. ...
883 views

### Specifying string patterns in DeleteCases

It seems that DeleteCases is not compatible with string patterns, at least directly (see, for example, this question). Is this true? If so, why is this the case? ...
282 views

### Access pairs of vectors, rather than the matrices, in partitioned data structure at a levelspec

I have some old code to analyze correlation between 2 time series by looking at windows of different lengths shifting across the time series data. The code: gets 2 sets of time series data (in ...
955 views

### position of sequence of elements in list [duplicate]

Possible Duplicate: Finding a subsequence in a list Question The position of {3, 5} is the list {1, 3, 4, 3, 5, 5, 1} is 3. How can such a position ...
87 views

### Need help to finish this prime signature function?

I'm trying to create a prime signature for line segments. ...
2k views

### Dealing with Empty Brackets in a List

I have a large list with varying constituent parts. Some of these are like this: i.e. graphlist[[34]] ...
252 views

### Built in way to de-list singletons?

Is there a built in method to de-list singleton expressions, like this rule-based solution: expr_ :> If[Length[expr] == 1, First@expr, expr] In data ...
2k views

### How do I check if any element in a list is positive?

As a simple example of what I would like to do, suppose I have a list a of all real numbers. I would like to perform a simple check to see if some element of ...
2k views

### How to generate table without comma and bracket or get rid of those?

I want just data without comma and brackets. Even TableForm is not working for me. For example, the general pattern of my table is ...
382 views

### How to extract strings from the list with an additional condition on previous elements?

There are a long list of strings $s$ and two lists of substrings $s1$ and $s2$. I want to take all elements of $s$ which contain a substring from $s2$ and such that before it on no more than $n$ ...
226 views

### Function[] argument nesting for operations like Select[]

The following code selects a special element from a list thelist = {"this", "notthis"}; Select[thelist, (# == "this") &] What I want is a function which ...
638 views

### Adding Lists Together

This is something that should be simple, but the documentation and other questions don't seem to deal with it. I can think of mechanically doing it through a loop, but I know there must be a better ...
2k views

### Finding all partitions of a set

I'm looking for straightforward way to find all the partitions of a set. IntegerPartitions seems to provide a useful start. But then things get a bit complicated. ...
250 views

### DateList coupled with String Operations

Through some webscraping, I have the following list: ...
235 views

### Taking only particular subsets and doing calculations

I have subsets formed from a list using the Subsets command and want to do a particular calculation, lets say subtraction using the ...
326 views

### How can the lowest non-zero value in a nested list be found and its position in the sublist returned?

In the example code below we have a list of triples that produce one or more sublists with at least one zero value. How can the positions of the lowest non zero value in each sublist be returned ...
2k views

### Mathematica Destructuring

Context I'm writing a function that look something like: ...
521 views

### Extracting parts of nested lists of rules using a syntax similar to JsonPath or Xpath

Given an example data set: ...
349 views

### Calculating average distance

I have a program that gives the average distance as the output. When I tried to repeat finding the average distance 100 times using Table, It failed to generate the output. This is the program. ...
208 views

### Expectation over a list with nested-mapped expressions

I need expected values of a list where the random variable to take expectations over should be an input into expressions defined earlier. I suspect Set[] and SetDelayed[] tripped me. (Or Map and ...
3k views

### Calculating the distance between the coordinates in a list

I have a list of coordinates {{A[9, 4, 7], 0.0395174}, {A[1, 5, 0], 0.0163797}, {A[0, 7, 2], 0.0577425}, {A[2, 7, 5], 1.01313}} I want to find the distance ...
364 views

### Formatting data tables with Grid + Dividers vs. SplitBy --> GridBy?

A quick method to format human-readable data tables with headers, is to use Grid, eg: ...
2k views

### How to select minimal subsets?

I am a newbie, so please point me in the right direction if you feel this question has been answered somewhere else before. Here goes: Suppose I have a list like this: ...
4k views

### How do I use Map for a function with two arguments?

I'm a newbie who tries to be a good boy, and use Map instead of writing out a list of functions. I have a table I want to Map ...
502 views

### Building a tree

Given a list of word characters, such as this one, I'd like to build a tree, similar to this makeTree function, but with the tree in a different format. So, for an input such as ...
1k views

### How to monitor the progress of Map?

I have a function doSomethingComplicated[...] that takes about 10s on average to evaluate. My list, listOfArgs has about 10000 ...
2k views

### Converting numbers to integers

I've read the available documentation but I still haven't found an NumberForm -> Integer function yet. No result in this site's search, either. Does it exist? ...
2k views

### Is there a way to output histogram x and y data without using the Histogram chart function?

I have a large list of data (3.2 million real numbers), and I would like to plot a histogram of it. The built-in Histogram function is very nice, but on my ...
125 views

### Obtaining EditDistance[] from a List of Strings

Consider the following question. I have a long selection of files (some 5,000), arranged linearly, and I want to view to what degree the files have changed between each other. For a small example, ...
682 views

### Elegant way to map a function to only the last element of each sublist [duplicate]

Suppose that I have the following list, called test: test = {{{a1}, {a2, a3}}, {{b1}, {b2, b3}}, {{c1}, {c2, c3}}}; Now ...
615 views

### Prepend 0 to sublists

My question is similar to this one, but my goal is to prepend a single 0 the each sublist, not incrementally many 0's. The file I'm working is a CSV containing around 50K sublists of length 35. I've ...
2k views

### Selecting elements from a list one by one

I have an list: l = {{4,5},{7,8},{9,5},{3,2},{1,2},{13,12}}. I want to take the elements in the list in the sequential order. For example the first element in ...
1k views

### Assigning a particular value to array elements

I have an array of 10000 elements. I want to randomly assign energy to these 10000 elements using Gaussian or Exponential distribution, such that each time a particular element is selected its energy ...