in reply to Perl Idioms Explained - keys %{{map{$_=>1}@list}}
Just as memory hungry, still not order preserving, and still broken with regards to undefined values, but faster approach:
And if you want to wrap it up without "leaking" lexicals:my %seen; @seen{@list}=(); my @uniq = keys %seen;
This approach does not (explicitly) iterate - more of the data structure setup work is done implicitly by perl.my @uniq = do { my %seen; @seen{@list}=(); keys %seen; };
Makeshifts last the longest.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Perl Idioms Explained - keys %{{map{$_=>1}@list}}
by Juerd (Abbot) on Aug 05, 2003 at 07:00 UTC | |
by Roy Johnson (Monsignor) on Feb 28, 2005 at 23:06 UTC | |
by pilcrow (Sexton) on Mar 02, 2005 at 06:54 UTC | |
by Roy Johnson (Monsignor) on Mar 02, 2005 at 12:19 UTC | |
by pilcrow (Sexton) on Mar 02, 2005 at 15:58 UTC | |
| |
Re: Re: Perl Idioms Explained - keys %{{map{$_=>1}@list}}
by Jenda (Abbot) on Aug 06, 2003 at 14:24 UTC | |
by Aristotle (Chancellor) on Aug 06, 2003 at 14:47 UTC |
In Section
Meditations