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

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



On Tue, Apr 18, 2000 at 06:24:59PM -0400, Uri Guttman wrote:
> >>>>> "RJK" == Ronald J Kimball <rjk@linguist.dartmouth.edu> writes:
> 
>   RJK> On Tue, Apr 18, 2000 at 06:03:18PM -0400, Uri Guttman wrote:
>   >> 
>   >> perl -pale'@r=map{$f=$_;map[@$_,$f],@r||[]}@F}for(@r){$_="@$_"'
>   >> 
>   >> why use ?: when || will do?
> 
>   RJK> || won't do here.  It puts @r in scalar context and yields the number of
>   RJK> elements, not the list of elements.
> 
> too true. seemed like a good idea but not tested. damn, i wanted to
> shorten that last one by at least 1 char!
> 

Oh, in that case:

perl -pale'@r=map{$f=$_;map[@$_,$f],@r?@r:[]}@F}for(@r){$_="@$_"'

perl -pale'@r=map{$f=$_;map[@$_,$f],@r?@r:0}@F}for(@r){$_="@$_"'


Heh heh.

Ronald

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