Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Extracting a series of duplicates

From: gabriele::colellachiara::com at: 5-Jul-2005 12:07

Hi David, On Tuesday, July 5, 2005, 4:46:23 AM, you wrote: D> I can't seem to find the right combination of functions to D> do this: Create a series containing the values that are D> repeated in another series. For example, if the first series is D> [1 2 2 3 4 5 5 5 6], the new series should be [2 5]. Any hints D> or solutions are appreciated. Is the series sorted? If so, what about: dups: [] lastval: none foreach element series [ if element = lastval [append dups element] lastval: element ] dups: unique dups (Note, actually this only needs that the duplicates are grouped, not that the series is sorted.) Regards, Gabriele. -- Gabriele Santilli <[gabriele--rebol--com]> --- Colella Chiara software division ---