Linked Questions

21 votes
5 answers
2k views

How to delete subsets quickly?

I have some data like this: ...
Apple's user avatar
  • 3,663
12 votes
5 answers
703 views

How do I prune a list of pairs of numbers so that each number occurs on only one pair?

How do I select only the first pair of numbers in which a number occurs from a list of pairs of numbers? For example, I have ...
orome's user avatar
  • 12.8k
10 votes
5 answers
487 views

Deleting list elements by comparing to another list

I have two lists as follow. The first is p={{"j","d","x"},{"d","k","z"}} and the second one is: ...
Wiliam's user avatar
  • 2,976
6 votes
5 answers
204 views

Delete the sublist which can be others' subsets

given lst = {{1, 5}, {2, 5}, {6, 8}, {6, 8, 9}} I want to remove all the sublists which is any other's subset. For the above example, remove ...
AsukaMinato's user avatar
  • 9,678
36 votes
4 answers
5k views

Looking for "Longest Common Substring" solution

I'm looking for robust code to solve the "Longest Common Substring" problem: Find the longest string (or strings) that is a substring (or are substrings) of two or more strings. I can just code it ...
Reb.Cabin's user avatar
  • 8,661
12 votes
4 answers
8k 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 ...
sjdh's user avatar
  • 7,757
9 votes
3 answers
1k views

Deleting quasi-duplicates from large list efficiently

I have the need to remove "duplicates" from large (>10K members) lists, where a "duplicate" is either a verbatim duplication, or the element's second entry exists as a first entry for some "earlier" ...
ciao's user avatar
  • 25.8k
6 votes
3 answers
683 views

Extracting Pareto elements from a list

How can I extract the Pareto elements from a list? For example, for that list: ...
Murta's user avatar
  • 26.2k
23 votes
2 answers
748 views

SetAttributes[f,Flat]: Why the order dependence?

I'm experiencing a strange phenomenon. Here's a (quite artificial) test case: The following definition work just fine: ...
celtschk's user avatar
  • 19.1k
8 votes
2 answers
263 views

Why does the name of a pattern affect the result of a transformation rule?

I was playing a little dirty, trying to get a template for defining a Curl[] operator. I wrote the following rule, which I knew was going to spit out a few ...
Dr. belisarius's user avatar
7 votes
2 answers
2k views

Classifying poker hands by pattern matching

I am working on this question posed in a Mathematica course revised in 1998. Here are the instructions: Poker Hands You are to define and show working examples of a function "...
Clif's user avatar
  • 697
3 votes
2 answers
99 views

How to delete that subset with succinct method? [duplicate]

I have a such list: data={{4, 2}, {4, 2, 3}, {4, 5}, {4, 2, 3, 5}, {4, 6}} Because the {4,2},{4,2,3},{4,5} is subset of ...
yode's user avatar
  • 26.7k
19 votes
1 answer
2k views

Get the name of a symbol passed to a function

I'm trying to get the name of a symbol passed to a function with this: f[x_] := {SymbolName[x], x} SetAttributes[f, HoldFirst] x = 5; f[x] But ...
Lorenzo Pistone's user avatar
16 votes
1 answer
639 views

Orderless pattern matching

The MMA docs state that "In matching patterns with Orderless functions, all possible orders of arguments are tried". Why then does the following not work? ...
sn6uv's user avatar
  • 565
2 votes
1 answer
246 views

Add Pattern to List Removing Duplicates

Lets say I have a list of patterns ...
William's user avatar
  • 7,595

15 30 50 per page