129k views

### Where can I find examples of good Mathematica programming practice?

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
7k views

### How to efficiently find positions of duplicates?

Is there an efficient way to find the positions of the duplicates in a list? I would like the positions grouped according to duplicated elements. For instance, given ...
2k views

### Given an ordered set S, find the points in S corresponding to another list

Given a sorted list of numbers $S$, I want to create a function that accepts a list of numbers $L$ and for each number $l \in L$ it returns the index of the largest number $s \in S$ such that $s<l$....
1k views

### Relational joining of tables

A common thing to want to do with data is to combine it (at least I thought this was a common thing). In SQL there is the idea of table joins "select id,v1,v2 from A,B where A.id=B.id" kind of thing. ...
679 views

### How to insert / merge a list into another list?

Background: I am working on a 2D geometry algorithm where I need to insert a list of 2D points into another list of 2D points. Somewhat to my surprise I found no Mathematica function capable of doing ...
246 views

### Inserting some zeros in a list by a rule of positions

I have a list: mainlist={0.23, 0.34, 0.8, 0.0, -0.2, 0.4, -0.1}; I have to extend the above list to another one finalresult ...
1k views

### Randomly selecting and reinserting a subset of elements in a list

This question is similar to my other question: How do I randomly select 'k' positions in a list and shuffle their respective elements without effecting the other elements? Imagine first a ...
173 views

### How to insert elements at different locations of a given list

Say a list is given as list = {a, b, c, d, r, m, n}; Suppose I want to insert 2 and 3 at position 3 and 7, respectively. ...
657 views

### Efficient method for Inserting arrays into arrays

This is strongly related to the following Questions: Looking for a way to insert multiple elements into multiple positions simultaneously in a list Building matrices by attaching vectors (columns) ...
219 views

### Rearranging elements of a list

I have a list: oldList = {"a-1", "b", "c", "a-2", "d", "e", "f", "a-3", "w"} and would like to get the following list: ...
301 views

### professionalize/optimize my code that calls a function

I have the following construction, which defines a function that I subsequently call in a loop multiple times. I use this very often, but I have never looked into if there is a more professional way ...
380 views

### How to double elements of a list given by their positions

Given that I have a list $\{P_0,P_1,P_2,\cdots,P_7\}$, where, $P_i$ is a real number or a list like {x,y}/{x,y,z}. Now I would like to double some elements ...