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

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



>>>>> "IP" == Ian Phillipps <igp_list2@tesco.net> writes:

  IP> The topic of APL came up today, and I recalled an APL one-liner (about
  IP> 150 chars if I recall) that printed a set of 4 Bridge hands in the
  IP> conventional layout.

wow. i wrote one of those in apl back in '74! i was just learning it and
it seemed like an interesting project. but back then apl matrices were
always even which meant i had to pad list of suit card in 
each hands to work. so my code was more than a one liner, it was a
couple of subs. today apl can have ragged matrices (more like perl's
LoL). it would be amusing if possible to find that code but i am sure it
has gone to the bit bucket in the sky.


apl did have the best way to shuffle and deal a bridge hand. this is
very rough and pseudo and probably wrong but the flavor is right:

	13 4 R 52 ? i 52

where

	R is rho (reshape a matrix)
	? is deal (i don't remember how to make sure that is a deal and
		  not a list of random picks)
	i is iota (index - generates 1 .. 52)

so that shuffles 1 .. 52 and reshapes it into 4 hands of 13. neat. can't
do that so easily in perl. i remember the formatting stuff was most of
the work due to the padding issues.

i will work on my perl version this weekend.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com

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