Re: [Haskell-cafe] A question about stack overflow

2006-06-29 Thread ihope
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

RE: [Haskell-cafe] A question about stack overflow

2006-06-27 Thread voigt . 16734551
--- 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 M

RE: [Haskell-cafe] A question about stack overflow

2006-06-27 Thread Huazhi (Hank) Gong
lto:[EMAIL 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 >

Re: [Haskell-cafe] A question about stack overflow

2006-06-27 Thread Udo Stenzel
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: m

Re: [Haskell-cafe] A question about stack overflow

2006-06-27 Thread Neil Mitchell
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 max

Re: [Haskell-cafe] A question about stack overflow

2006-06-27 Thread Donald Bruce Stewart
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"

Re: [Haskell-cafe] A question about stack overflow

2006-06-27 Thread Chris Kuklewicz
Huazhi (Hank) Gong wrote: > 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 [

[Haskell-cafe] A question about stack overflow

2006-06-27 Thread Huazhi (Hank) Gong
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 [x] = x myMax [x:xs] = if x>= (myMax