[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: recursion, stacksize & linux
From:       Andreas Schlapbach <schlpbch () iamexwi ! unibe ! ch>
Date:       2000-12-11 17:14:51
[Download RAW message or body]

Doug Welzel wrote:
> 
> I believe compilers can (will) transform recursion into loops in the case
> of tail recursion.  I don't have an example offhand though.  If you search
> around the web for tail recursion you might come up with something.  I'll
> take a look and see if I can find anything.
> 

Tail recursion

Not tail recursive, last operation is '+':

f(x) {
  return f(x) + 2 
}

Tail recurrsive, last operation is the call to the recurrsive function:

f(x) {
  return f(x+2)
}

The second one can be optimized by the compiler.

I can elaborate some more if somebody is interested :-)

Andreas

-- 

>> Linux - Where do you want to go tomorrow? <<

Andreas Schlapbach
mailto:schlpbch@iamexwi.unibe.ch
http://iamexwiwww.unibe.ch/studenten/schlpbch
 
>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic