On Sat, May 19, 2007 at 04:10:29PM +0100, Jon Fairbairn wrote:
[...]
> 
> > foldl f z l = case l of
>                 (x:xs) -> foldl f (f z x) xs
>                 [] -> z
> 
> which reveals that foldl in the RHS isn't really the
> leftmost outermost function, but case is -- the tail call is
> to case. It happens that case is a kind of function that
> makes a choice -- it returns one of its arguments but
> doesn't do anything more to it. In a strict language only
> some predefined operators like case and if have this
> property, but lazy languages allow the definition of new
> ones, which is why we need more care when thinking about
> tail calls.
By definition, tail recursive function is recursive function in which
the value returned from a recursive call is immediately returned without
modification as value of the top-level invocation, which is true for
foldl defined as above.
> 
> -- 
> Jón Fairbairn                                 [EMAIL PROTECTED]
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to