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

Re: [FWP] Cartesian Cross-Products in one <80 char line




Did it!  (somebody gimme a cigarette!)



perl
-lane'BEGIN{@r=[]}END{print"@$_"for@r}@r=map{$f=$_;map{[@$_,$f]}@r}@F'

the reverse can be eliminated by switcing the order in the
innermost map, and the join can be eliminated by double-quoting the
array, which automatically joins the array elements with the space
character.

-l prints a new line at the end of every print statement
-n causes the body to be wrapped in while(<>){BODY GOES HERE}
-a causes the body to be preceded with @F=split; # F for "Fields"
-e causes execution of command line argument

BEGIN and END blocks are executed before and after the main code body,
respectively.

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