develooper Front page | perl.golf | Postings from July 2002

Re: Golf this.

Thread Previous | Thread Next
From:
Tor Hildrum
Date:
July 15, 2002 23:23
Subject:
Re: Golf this.
Message ID:
B959884F.CCD2%torhildr@mac.com
<Andrew.Savige@ir.com> wrote:

>> open F,$_[0];while(<F>){$h{$_}=$i;}foreach$k(%h){print"$k";}
               ^^^^^
Should be $ARGV[0]

> Yours removes duplicates but does not sort.
> How about this?
> 
> #!perl -p
> $h{$_}=""}for(sort%h){

Ah. :)
{$h{$_}=""}for(sort%h){print}

Gives an additional newline at the start though.

But, is this the shortest algorithm? Using a hash?
29 strokes?

Tor


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About