Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Recursion HALP

Name: Anonymous 2011-06-01 2:33

Hey /prog/, I must say my understanding of recursion is shit (never really dealt with recursion in all my days of writing bad code). How should I go about thinking about it?

inb4 flaming: I understand the recursive concept in some contexts, such as when it is used in a factorial function, but when it starts getting more ambiguous (say, exercise 5, ch. 2 from ANSI Common Lisp) it's ugly.

inb4 RECURSE MY ANUS

Name: Anonymous 2011-06-01 20:50

>>29
Are you even reading my responses?
fact could be a variable. It does not vary in most implementations of factorial. It is a function, which is not a mathematical variable. Therefore it could be a "C/C++" variable. IHBT. You cease expanding (and thus start evaluating) fact when it becomes the base case, here it is 1. So the diagram (not my diagram, please refer to >>28) would end up as (* 5 (* 4 (* 3 (* 2 (1))))) before the evaluation of the products. Which is the point and time (?,>>22) that you start to "do" the multiplications.

Now please, stop being an anus, I've had to repeat myself as many times as you here.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List