wiki:Functions/Max

max, maximum

(define max (lambda (x y)
                (if (> x y)
                    x
                    y)))
max x y  =  case (x > y) of
               True  -> x
               False -> y
maximum []  =  errorEmptyList "maximum"
maximum xs  =  foldl1 max xs
max([H|T]) -> max(T, H).

max([H|T], Max) when H > Max -> max(T, H);
max([_|T], Max)              -> max(T, Max);
max([],    Max)              -> Max.
Last modified 4 years ago Last modified on Nov 3, 2016, 12:52:27 PM
Note: See TracWiki for help on using the wiki.