|
|
| P is for Practical | |
| PerlMonks |
Re^4: How am i doing?by LanX (Saint) |
| on Jul 21, 2025 at 10:20 UTC ( [id://11165733]=note: print w/replies, xml ) | Need Help?? |
|
ChatGPT agrees, HOW CAN I BE WRONG? ;-P
<Reveal this spoiler or all in this thread> Yes I'm sure, because I've seen it multiple times used this way, IIRC also in HOP. The F(n) = F(n-1) + F(n-2) for n > 1 part is straightforwardly implemented with recursion. > implementing the Fibonacci sequence by recursion is very ineffective. (Slightly nitpicking) It's inefficient but effective! The point is you get a correct result, even if you waste processing power. The "memoisation" you mentioned solves this efficiency problem of needlessly recalculating known results. IOW, the schoolbook continues evolving the example to deeper depth (sic). Keep in mind that the classic MIT lectures on programming used to be in Lisp and original Lisp didn't have loops, only those "tail recursions".
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||||||||