Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: rule based program for "Deleting repeated members of a list."

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81952] Re: [mg81917] rule based program for "Deleting repeated members of a list."
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Sun, 7 Oct 2007 05:38:07 -0400 (EDT)
  • References: <3539354.1191662363404.JavaMail.root@m35>
  • Reply-to: drmajorbob at bigfoot.com

s = RandomInteger[10, 20]

{5, 9, 10, 7, 7, 4, 6, 10, 8, 0, 9, 7, 5, 2, 8, 8, 4, 4, 3, 6}

Tally[s][[All, 1]]

{5, 9, 10, 7, 4, 6, 8, 0, 2, 3}

That's the unsorted union, and here's the sorted version:

Union@s

{0, 2, 3, 4, 5, 6, 7, 8, 9, 10}

The latter is slower, of course.

Bobby

On Sat, 06 Oct 2007 03:47:04 -0500, mumat <csarami at gmail.com> wrote:

> Hi,
>
> I have a list s={a,b,c,c,d,e,e,f,g,g,g,h,a,b};
>
> I need to write a program so that it reads the list and ignors
> repeated elements; so it outputs the following:
>
> RepeatRemover[s]={a,b,c,d,e,f,g,h,a,b};
>
> I am looking for a rule-based program to do this!
>
> Any help would be greatly appreciated.
>
> C.S.
>
>
>



-- =

DrMajorBob at bigfoot.com


  • Prev by Date: Re: Why is FindRoot[] HoldAll?
  • Next by Date: RE: rule based program for "Deleting repeated members of a list."
  • Previous by thread: Re: rule based program for "Deleting repeated members of a list."
  • Next by thread: Re: rule based program for "Deleting repeated members of a list."