Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
jberryman
GHC
Commits
adc02cf2
Commit
adc02cf2
authored
Aug 29, 2001
by
simonmar
Browse files
[project @ 2001-08-29 10:12:34 by simonmar]
update maximumBy and minimumBy in line with the revised Haskell 98 report
parent
ed69dbe9
Changes
1
Hide whitespace changes
Inline
Side-by-side
ghc/lib/std/List.lhs
View file @
adc02cf2
% -----------------------------------------------------------------------------
% $Id: List.lhs,v 1.1
2
2001/0
6
/2
5
1
3
:1
3:58
simon
pj
Exp $
% $Id: List.lhs,v 1.1
3
2001/0
8
/2
9
1
0
:1
2:34
simon
mar
Exp $
%
% (c) The University of Glasgow, 1994-2000
%
...
...
@@ -323,13 +323,21 @@ insertBy cmp x ys@(y:ys')
GT -> y : insertBy cmp x ys'
_ -> x : ys
maximumBy :: (a -> a -> a) -> [a] -> a
maximumBy _ [] = error "List.maximumBy: empty list"
maximumBy max xs = foldl1 max xs
minimumBy :: (a -> a -> a) -> [a] -> a
minimumBy _ [] = error "List.minimumBy: empty list"
minimumBy min xs = foldl1 min xs
maximumBy :: (a -> a -> Ordering) -> [a] -> a
maximumBy _ [] = error "List.maximumBy: empty list"
maximumBy cmp xs = foldl1 max xs
where
max x y = case cmp x y of
GT -> x
_ -> y
minimumBy :: (a -> a -> Ordering) -> [a] -> a
minimumBy _ [] = error "List.minimumBy: empty list"
minimumBy cmp xs = foldl1 min xs
where
min x y = case cmp x y of
GT -> y
_ -> x
genericLength :: (Num i) => [b] -> i
genericLength [] = 0
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment