develooper Front page | | Postings from July 2002

Re: Golf this.

Thread Previous | Thread Next
Tor Hildrum
July 15, 2002 23:23
Re: Golf this.
Message ID:
<> 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. :)

Gives an additional newline at the start though.

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


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About