minimumBy and maximumBy

Koen Claessen
Fri, 5 Apr 2002 13:56:05 +0200 (MET DST)

Dear all,

Has anyone ever noticed that the functions 'maximumBy' and
'minimumBy' from the Prelude are really the same function?
Both are defined as:

  maximumBy, minimumBy :: (a -> a -> a) -> [a] -> a
  maximumBy max xs = foldl1 max xs
  minimumBy min xs = foldl1 min xs

Is there any reason for this?


Koen Claessen
Chalmers University, Gothenburg, Sweden.