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
maximum (a:b:xs) = maximum (max a b : xs)

Thanks

Neil
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to