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

Re: [FWP] Recursion, anyone?



On Apr 11, yanick1@sympatico.ca said:

>On Thu, Apr 12, 2001 at 12:35:54AM +0200, Abigail wrote:
>> > On Wed, Apr 11, 2001 at 04:49:14PM -0400, Yanick Champoux wrote:
>> > #!/usr/bin/perl
>> > @e=(A..Z,a..z,0..9,'-');@i=(0)x shift;$\="\n";while($f=1){print@e[@i];
>> > $f&&((++$_>@e?$_:$f)=0)for@i;$f&&exit}
>
><snip Abigailistic wisdom>
>
>Using those tricks and changing a shift to pop gives us:
>
>
>#!/usr/bin/perl
>@e=(A..Z,a..z,0..9,'-');@i=(0)x pop;{$f=print@e
>[@i],"\n";$f&&((++$_>@e?$_:$f)=0)for@i;$f||redo}

#!/usr/bin/perl
@e=(A..Z,a..z,0..9,'-');@i=(0)x pop;{$f=print@e
[@i],$/;$f&&((++$_>@e?$_:$f)=0)for@i;$f||redo}

Just a "\n" -> $/ optimization.

-- 
Jeff "japhy" Pinyan      japhy@pobox.com      http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734


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