[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Sort challenge



Today around 12:09am, Uri Guttman hammered out this masterpiece:

: >>>>> "KCI" == Keith Calvert Ivey <kcivey@cpcug.org> writes:
: 
:   KCI> Uri Guttman <uri@sysarch.com> wrote:
:   >> >>>>> "CRT" == Casey R Tweten <crt@kiski.net> writes:
:   >> 
:   >> print sort{lc$a cmp lc$b}
:   >> map{/(.*)\|(.*)\|(.*)/;($2?"$2${$3&&\qq{, $3}}":$1).$/}<>
:   >> 
:   >> cut off 2 more.
: 
:   KCI> Why all this messing about with join() or, worse, a reference- 
:   KCI> based interpolation, when the straightforward concatenation 
:   KCI> operator gives a solution 5 strokes shorter than Uri's?
: 
:   KCI>            print sort{lc$a cmp lc$b}
:   KCI>            map{/(.*)\|(.*)\|(.*)/;($2?$2.($3&&", $3"):$1).$/}<>
: 
:   KCI> Am I missing something?
: 
: well, i said that dealing with $3 was the main issue left. i just was
: under too much time pressure (going out) to get that solution. :)
: and why i did the ref interpolation is that it beat join. i never seem
: to use . by itself even when it wins like here. 

81 characters:

print sort{lc$a cmp lc$b}
map{/(.*)\|(.*)\|(.*)/;($2?$2.($3&&", $3"):$3||$1).$/}<>


-- 
print(join(' ', qw(Casey R. Tweten)));my $sig={mail=>'crt@kiski.net',site=>
'http://home.kiski.net/~crt'};print "\n",'.'x(length($sig->{site})+6),"\n";
print map{$_.': '.$sig->{$_}."\n"}sort{$sig->{$a}cmp$sig->{$b}}keys%{$sig};
my $VERSION = '0.01'; #'patched' by Jerrad Pierce <belg4mit at MIT dot EDU>


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe