Re: easiest way to sort a list?
- To: mathgroup at smc.vnet.net
- Subject: [mg18326] Re: [mg18308] easiest way to sort a list?
- From: "David Park" <djmp at earthlink.net>
- Date: Sat, 26 Jun 1999 19:08:04 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Peter Wang wrote:
>Hi everyone,
>
>Here's my question: Suppose you have a list of integers, not all distinct,
>say
> {1, 5, 3, 5, 10, 10, 1},
>
>and you want to obtain the list
>
> {1, 5, 3, 10}
>
This rule should do it, although I am not certain about efficiency. Those are triple
and double "blanks" in the rule.
rule = {a___, b__, c___, b__, e___} -> {a, b, c, e}
{1, 5, 3, 5, 10, 10, 1} //. rule
{1, 5, 3, 10}
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/