On 6/27/06, Udo Stenzel [EMAIL PROTECTED] wrote:
Neil Mitchell wrote:
Or if you don't want to go for a fold next, in a style more similar to
the original:
maximum [] = undefined
maximum [x] = x
maximum (a:b:xs) = maximum (max a b : xs)
It even reproduces the stack overflow, though for a
hankgong:
Hi, all
I'm just a newbie for Haskell and functional programming
world. The idea I currently read is quite different and
interesting.
I have one general question about the recursively looping
style. For example:
myMax [ ] = error empty list
myMax
Hi,
mymax [] = undefined
mymax (x:xs) = f x xs
where
f x [] = x
f x (y:ys) | y x = f y ys
| otherwise = f x ys
Or if you don't want to go for a fold next, in a style more similar to
the original:
maximum [] = undefined
maximum [x] = x
Neil Mitchell wrote:
Or if you don't want to go for a fold next, in a style more similar to
the original:
maximum [] = undefined
maximum [x] = x
maximum (a:b:xs) = maximum (max a b : xs)
It even reproduces the stack overflow, though for a different reason.
Better write it this way:
PROTECTED]
Sent: Tuesday, June 27, 2006 5:34 PM
To: Huazhi (Hank) Gong
Cc: haskell-cafe@haskell.org
Subject: Re: [Haskell-cafe] A question about stack overflow
Huazhi (Hank) Gong wrote:
Hi, all
I'm just a newbie for Haskell and functional programming world. The idea
I currently read is quite
--- Huazhi (Hank) Gong [EMAIL PROTECTED] wrote:
Thank you very much
for introducing tail recursion.
It's my first time to hear this. :)
However, I'm wondering whether every loop structure from C like language can
be translated to this kind of tail recursion?
Yes, as discovered by
John