Hi, Mark Overmeer wrote: > * Ingo Blechschmidt ([EMAIL PROTECTED]) [050519 16:52]: >> Should it be possible to give an own comparator block, similar as >> with grep? E.g. >> uniq <a b a a c d>; # <a b a c d> >> >> uniq:{ abs $^a == abs $^b } 42, 23, -23, 23, 42 >> # 42, 23, 42 > > 'uniq' differs from 'sort' because there is no order relationship > between > the elements.
quoting Damian's original mail[1]: > uniq - remove duplicates without reordering ^^^^^^^^^^^^^^^^^^ > A quick algorithm for finding the unique elements in > perl5 is [...] Yeah, or the Perl 6: sub uniq([EMAIL PROTECTED]) { my %h; [EMAIL PROTECTED]; return keys %h; } # Or sub uniq([EMAIL PROTECTED]) { my %h; [EMAIL PROTECTED] = (undef) xx Inf; return keys %h; } # thousand other ways ommitted :) --Ingo [1] http://groups.google.com/groups?selm=420DB295.3000902%40conway.org -- Linux, the choice of a GNU | "The future is here. It's just not widely generation on a dual AMD | distributed yet." -- William Gibson Athlon! |