Re: [Haskell-cafe] Definition of tail recursive wrt Folds

2009-03-28 Thread Tillmann Rendel
Brent Yorgey wrote: What, strictly speaking, is the definition of ”tail recursive” as opposed to just “recursive”? A recursive function is tail recursive if the final result of the recursive call is the final result of the function itself. If the result of the recursive call must be further

Re: [Haskell-cafe] Definition of tail recursive wrt Folds

2009-03-28 Thread Isaac Dupree
Tillmann Rendel wrote: Now consider a variant: if' a b c = if a then b else c variant x = if' (p x) (f x) (g x) I would say that if' has the same operational behavior as an if-then-else expressions, and therefore, (f x) and (g x) are still tail cails, even if they now appear in the

Re: [Haskell-cafe] Definition of tail recursive wrt Folds

2009-03-28 Thread Lennart Augustsson
You are absolutely right. The concept of tail call is not quite as easy to define in Haskell as some people seem to think. It is, after all, an operational concept. In your example if' a b c = if a then b else c variant x = if' (p x) (f x) (g x) the variant function tail calls if', and if'

[Haskell-cafe] Definition of tail recursive wrt Folds

2009-03-25 Thread Mark Spezzano
Hi, Just looking at the definitions for foldr and foldl I see that foldl is (apparently) tail recursive while foldr is not. Why? Is it because foldl defers calling itself until last whereas foldr evaluates itself as it runs? What, strictly speaking, is the definition of ”tail

Re: [Haskell-cafe] Definition of tail recursive wrt Folds

2009-03-25 Thread 司馬泰
wikipedia is your friend... http://en.wikipedia.org/wiki/Fold_(higher-order_function) Tammo 2009/3/25 Mark Spezzano mark.spezz...@chariot.net.au: Hi, Just looking at the definitions for foldr and foldl I see that foldl is (apparently) tail recursive while foldr is not. Why? Is it

Re: [Haskell-cafe] Definition of tail recursive wrt Folds

2009-03-25 Thread Brent Yorgey
On Wed, Mar 25, 2009 at 05:54:17PM +1030, Mark Spezzano wrote: What, strictly speaking, is the definition of ”tail recursive” as opposed to just “recursive”? A recursive function is tail recursive if the final result of the recursive call is the final result of the function itself. If the