Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

(MeowChow) Re: isn't unless ! $c the same than if $c ?

by MeowChow (Vicar)
on Apr 03, 2002 at 23:41 UTC ( #156492=note: print w/ replies, xml ) Need Help??

in reply to isn't unless ! $c the same than if $c ?

The recursive return value for the $c == 0 case in both code samples is not properly specified, so the return value is set to the value of the compared expression, !$c in the first case, and $c in the second. What you should have written was something like:
perl -le 'sub a{my$c=pop;print $c;$c?$c*a($c-1):1}print a(--$ARGV[0])' + 5

               s aamecha.s a..a\u$&owag.print

Comment on (MeowChow) Re: isn't unless ! $c the same than if $c ?
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://156492]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (13)
As of 2015-08-28 12:52 GMT
Find Nodes?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...

    Results (336 votes), past polls