Linked Questions

602 votes
19 answers
156k 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 ...
78 votes
9 answers
12k 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 ...
Michael E2's user avatar
  • 236k
22 votes
7 answers
1k views

Reproducing a ranking function that behaves like Excel's RANK

I tried to find a function or expression in Mathematica that produces the same output as the RANK function in Excel (see its description here), but unfortunately I ...
Mehmet's user avatar
  • 587
13 votes
6 answers
936 views

Efficiently finding the positions of a large list of targets in another, even larger list

I have a big list. It contains nearly 60,000 sub-lists. It's structured like bigList = {{x1,y1,z1},{x2,y2,z2},{x3,y3,z3},.....,{x60000,y60000,z60000}}; I have ...
subbu's user avatar
  • 2,304
19 votes
4 answers
653 views

Retaining and reusing a one-to-one mapping from a sort

Imagine I sort the elements of an array $Q$ by some means. Perhaps I sort strictly by the elements in the first column, perhaps I use SortBy[...] to sequentially sort by the elements in successive ...
Roger Harris's user avatar
  • 1,497
11 votes
4 answers
1k views

Gather list elements by labels

The following list has some elements that are labeled. For example {1, 2} -> 1, {-1, 3} -> 3, etc: ...
tchronis's user avatar
  • 2,445
8 votes
7 answers
418 views

While partitioning the elements in a list using GatherBy, can I correspondingly partition the elements of an unrelated list?

If we have a list like the following: list1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; And we use GatherBy to subpartition is ...
SShepard's user avatar
  • 117
9 votes
3 answers
867 views

GatherBy/SplitBy and Sort a list

So let's say I want to group a list of points based on their distance from the origin. I would do something like: ...
Shb's user avatar
  • 701
3 votes
7 answers
358 views

Returning all positions for all different occurences of elements in a list

Is there way to construct oneliner as pure function(s), so that I enter mylist only on one place - on the end of line. And that function return the same result as ...
Dragutin's user avatar
  • 920
23 votes
1 answer
692 views

Underlying Algorithms for List Manipulation Functions

Does anyone know, or know of a link for the underlying algorithms used for list manipulation functions? Specifically: Union with and without the ...
Jonie's user avatar
  • 1,199
2 votes
2 answers
424 views

How to drop the identical rows and columns of a matrix?

I'm currently trying to find a way to eliminate from a square matrix of generic dimension the duplicate (up to sign) rows and columns, obtaining a smaller dimensional matrix. I searched around here ...
Stefano's user avatar
  • 23