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

Re: [FWP] APL vs. Perl. A query from a lazy programmer.



Today around 6:10pm, Casey R. Tweten hammered out this masterpiece:

: Today around 3:42pm, Ian Phillipps hammered out this masterpiece:
: 
: : The topic of APL came up today, and I recalled an APL one-liner (about
: : 150 chars if I recall) that printed a set of 4 Bridge hands in the
: : conventional layout.
: 
: I'm not about to try for 150 chars but here's mine before I drive home
: from work and find a better way ;-)
: 
: : Having more laziness and impatience than hubris at the moment, I
: : wondered if fwpers would rise to the challenge of duplicating this
: : feat...
: 
: #!/usr/bin/perl -l
: 
: @s=qw(S H D C);
: $c=join'',@c=(qw(A K Q J T),reverse(1..9));

So what, I have a card named '1'.  Just back off ;-)
The rest of the code will work correctly if the above is fixed.

: @d=sort{rand()<=>rand}map{$s=$_;map{[$s,$_]}@c}@s;
: sub h{index($c,$a)<=>index$c,$b}
: 
: for $p ( 1..4 ) {
:  push@{$h{$p}{$_->[0]}},$_->[1]for@d[13*$p-14 .. 13*$p-2];
:  $p==3?print map{"$_: ".join('',sort h@{$h{$p-1}{$_}}).
:   (' 'x(21-@{$h{$p-1}{$_}}))."$_: ".join('',sort h@{$h{$p}{$_}})."\n"}@s
:  :print map{(' 'x13)."$_: ".join('',sort h@{$h{$p}{$_}})."\n"}@s
:  if$p!=2
: }
: 
: 
: 

-- 
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