361 views

### Find the identical rows in a matrix [duplicate]

Suppose I have the following matrix: ...
243 views

### Using Select in Subsets [duplicate]

I have a list: list = {{7, 6, 14, 14, 4}, {4, 9, 8, 11, 14}, {20, 12, 12, 11, 3}, {7, 4, 11, 7, 20}, {2, 13, 17, 11, 19}} I did a test to identify where ...
130k 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 ...
5k views

### Partitioning with varying partition size

How can I partition a list into partitions whose sizes vary? The length of the $k$'th partition is a function $f(k)$. For example: if $l = \{1, 2, 3, 4, 5, 6\}$ and $f(k) = k$. Then the partitioning ...
4k views

### How to get list of duplicates when using DeleteDuplicates?

This might be easy, but can't find a way to use DeleteDuplicates to get also list of the actual duplicates. Example: ...
5k views

### Delete duplicate elements from a list

If a list contains duplicate elements, for example list = {a, 1, 5, 3, 5, x^2, x^2}, how can the duplicate elements be removed? The result would be ...
3k views

### Looking for a way to insert multiple elements into multiple positions simultaneously in a list

I would like to take the following data: insertValues = {r, x}; insertPositions = {{1}, {5}}; originalList = {a, b, c, d, e, f, g}; and generate output that ...
1k views

### How do I obtain an intersection of two or more list of lists conditioned on the first element of each sub-list?

Given two lists like list1 = {{1, 1}, {2, 4}, {3, 9}, {4, 16}}; list2 = {{2, 6}, {3, 9}, {4, 12}, {5, 15}}; I would like to produce an output like ...
740 views

### Partitioning a list when the cumulative sum exceeds 1

I have a long list of say 1 million Uniform(0,1) random numbers, such as: dat = {0.71, 0.685, 0.16, 0.82, 0.73, 0.44, 0.89, 0.02, 0.47, 0.65} I want to ...
516 views

### Pick elements from list “separately”

I have the following list I want to pick elements from: mylist = {1, 5, 7, 3, 4, 7, 2, 9, 9, 1, 10, 12, 2, 64, 34, 64} I have another list with 0's and 1's which ...
1k views

### Why is the new PositionIndex horribly slow?

This issue has largely been mitigated in 10.0.1. New timings for the final test below are: ...
459 views

### Positions of elements in the initial flattened list in a split list

Say, we have a list: m1 = {2, 2, 7, 0, 7, 7, 2, 2, 2} It can be split easily: ...
816 views

### Easiest/most efficient way to delete duplicates from one list at the positions of another?

This question is somewhat related to How to efficiently find positions of duplicates? , although I'm interested in something a little bit simpler since I'm not really interested in a list of all the ...