This is the mail archive of the automake@gnu.org mailing list for the automake project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: More fixes for assembler support


In article <87lnfa80om.fsf@cygnus.com>, Tom Tromey wrote:
>>>>>> "Pavel" == Pavel Roskin <pavel_roskin@geocities.com> writes:
>Pavel> 4) Just in case, %suffixes renamed to %uniquify, to avoid using
>Pavel> @suffixes and %suffixes in the same procedure. Is there "sort
>Pavel> -u" in Perl?
>
>I think it is safe to have a hash and a list with the same name.

It's safe for perl - potentially confusing for the programmer if abused, but
I'd argue it's actually helpful if they serve the same purpose as in this
case.

>I don't know of a `sort -u'; I always use a hash.  I suppose we could
>write a convenience function, but it hasn't seemed important.

Using a hash is probably a good a way as any, though it is likely to eat a
lot of memory if your array is enormous.  Alternatively you can use map like
this to "uniq" the array after sorting it:

my $x;
@out = map {$_ eq $x ? () : ($x = $_)} sort @in

That's perl 5 code BTW.

Cheers,
Olly


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]