[Haskell-cafe] A question about stack overflow

ihope ihope127 at gmail.com
Thu Jun 29 10:38:56 EDT 2006


On 6/27/06, Udo Stenzel <u.stenzel at web.de> 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 different reason.

How about this:

maximum (a:b:xs) = maximum ((: xs) $! max a b)

--ihope


More information about the Haskell-Cafe mailing list