[Haskell-beginners] Understanding recursion in Haskell.

Thomas Davie tom.davie at gmail.com
Wed Mar 18 11:39:47 EDT 2009


On 18 Mar 2009, at 16:32, Zachary Turner wrote:

> A few others have given more complete walkthroughs / traces of the  
> executions, but just to add a little.  When it finally "clicked"  
> with me and recursion became easier to understand, it was when I  
> stopped trying to think about the entire execution chain.  For  
> example, let's say I run a ticket resale (scalping) shop and someone  
> calls me and says "hey I need two tickets for the show this  
> saturday."  I tell the guy sure no problem, I'll call you back in 2  
> hours.  But actually I don't have the tickets, so I call one of my  
> connections.   Unfortunately, he doesn't have the tickets either so  
> this process ends up repeating for a while.  When I talk to my  
> connection on the phone I don't think "ok he's going to call John,  
> and John's probably going to call William, and then William might  
> call Frank, etc".  I just think "he's either going to call me back  
> and say yes or no, regardless of how he arrives at that answer".   
> That's the key to recursion.

This, and the fact that Frank does not call you looking for tickets  
(i.e. we must always make some progress).

Bob


More information about the Beginners mailing list