Todd Rockhold wrote: > > Clever. Etienne, how about submitting it to TPJ as a one-liner? It's not > strictly one line, but many I've seen published there aren't. > > > > >sub cartesian { > > > my @res = [] ; > > > @res = map {$a=$_;map {[$a,@$_]} @res} @$_ for reverse @_ ; > > > @res ; > > >} > > > > Wow, I understand that completely, and it's damn fast. It could easily enough become a one-liner, but how do you get multiple sets in from stdin? words on each line perhaps? Pipe some haiku through this baby: perl -e'@r=[];@r=map{$a=$_;map{[$a,@$_]}@r}@$_ for reverse map{[split]}<STDIN>;print join" ",@$_,"\n" for@r' with command line switches and an END block for the printing, it can be made shorter perl -lane'END{@r=[];@r=map{$a=$_;map{[$a,@$_]}@r}@$_ for@I;print join" ",@$_ for@r}push@I,[@F]' or perl -lane'END{print(join$",reverse@$_)for@r}BEGIN{@r=[]}@r=map{$a=$_;map{[$a,@$_]}@r}@F' __________________________________________________________________ David Nicol 816.235.1187 nicold@umkc.edu make: *** No rule to make target `lawless'. Stop. ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe