[prog] functions

Finne Boonen fboonen at vub.ac.be
Mon Jan 12 13:21:42 EST 2004


On Mon, 12 Jan 2004 cristofd at hevanet.com wrote:

> > What is the 
> > difference between recursion and iteration
> > and why would you chose to use one over the other?
> 
> Iteration involves an explicit command to perform some set of actions 
> repeatedly until some condition holds; in C++ this is typically done 
> with a while loop or a for loop.
> Recursion involves a function which performs some set of actions and 
> also calls itself (directly or indirectly) unless some condition holds; 
> in C++ the self-call is put directly into the function definition.

not really correct: iteration -> doing some thing again and again, trough 
a for loop or through calling itself

recursion is repeating something and doing something with the function
afterwards. 

actually, a better discussion about this subject is found in Structure and
Interpretation of Computer programms, by Abelson & Sussman, you can find
it online but I don't have the link here.

Finne
***********************************************************************************************
normally reserved for signatures
currently lacking one



More information about the Programming mailing list