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

Re: Golf this.

Thread Previous | Thread Next
From:
Andrew.Savige
Date:
July 15, 2002 23:08
Subject:
Re: Golf this.
Message ID:
694BB7191495D51183A9005004C0B05452DE7D@ir-exchange-srv.ir.com.au
En op 16 juli 2002 sprak Tor Hildrum:
>I was considering starting a first ever newbie golf hole,
> but I chickened out.
>
> I would still like some help with golfing my solution down a couple of
> strokes. It's pretty trivial:
>
> open F,$_[0];while(<F>){$h{$_}=$i;}foreach$k(%h){print"$k";}'
>
> It's basically just supposed to copy the 'sort -u' function.
> I'm pretty satisfied with it, but I'm pretty sure there is another
(better)
> algorithm. 

Yours removes duplicates but does not sort.
How about this?

#!perl -p
$h{$_}=""}for(sort%h){

/-\

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