On 11/07/2013, at 2:47 PM, Dale Fraser <[email protected]> wrote:

> I love recursive functions, just don’t see them often, makes me think of a 
> lot of other uses for them I’ve never considered.

Cool, inspiration is good :-). This is a classic functional programming 
approach - start with the result (an empty input and a completed output) then 
work out the step-wise process to get there from the input.

I should point out that because the recursion is on the last line of the 
function this is "tail recursive" - the compiler will notice this and optimise 
the code by throwing away the current stack frame (which would have been used 
by later statements in the function had they existed) each time the recursive 
call is made, so you don't need to worry about a stack overflow - this is how 
functional languages iterate efficiently.

Cheers,
Robin


 


Robin Hilliard
Chief Technology Officer


RocketBoots Pty Ltd
Level 11
189 Kent Street
Sydney NSW 2001
Australia       map
Phone   +61 2 9323 2507
Facsimile       +61 2 9323 2501
Mobile  +61 418 414 341
email           [email protected]
web             www.rocketboots.com.au










-- 
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cfaussie.
For more options, visit https://groups.google.com/groups/opt_out.


<<inline: rb_logo.png>>

Reply via email to