
27 Jun
2006
27 Jun
'06
6:11 a.m.
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: maximum [] = undefined maximum [x] = x maximum (a:b:xs) = let m = max a b in m `seq` maximum (m : xs) Udo. -- "The condition of man is already close to satiety and arrogance, and there is danger of destruction of everything in existence." -- a Brahmin to Onesicritus, 327 BC, reported in Strabo's Geography