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
96009cf5
Commit
96009cf5
authored
Aug 28, 2001
by
simonmar
Browse files
[project @ 2001-08-28 15:12:37 by simonmar]
Bring scanr1, scanl, and scanl1 into line with the revised H98 report.
parent
fce821ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
ghc/lib/std/PrelList.lhs
View file @
96009cf5
% ------------------------------------------------------------------------------
% $Id: PrelList.lhs,v 1.2
6
2001/08/28 15:
07:58
simonmar Exp $
% $Id: PrelList.lhs,v 1.2
7
2001/08/28 15:
12:37
simonmar Exp $
%
% (c) The University of Glasgow, 1994-2000
%
...
...
@@ -176,9 +176,9 @@ scanl f q ls = q : (case ls of
[] -> []
x:xs -> scanl f (f q x) xs)
scanl1
:: (a -> a -> a) -> [a] -> [a]
scanl1 f (x:xs)
= scanl f x xs
scanl1 _ []
= errorEmptyList "scanl1"
scanl1
:: (a -> a -> a) -> [a] -> [a]
scanl1 f (x:xs)
= scanl f x xs
scanl1 _ []
= []
-- foldr, foldr1, scanr, and scanr1 are the right-to-left duals of the
-- above functions.
...
...
@@ -194,10 +194,10 @@ scanr f q0 (x:xs) = f x q : qs
where qs@(q:_) = scanr f q0 xs
scanr1 :: (a -> a -> a) -> [a] -> [a]
scanr1 _ [x] = [x]
scanr1 f (x:xs) = f x q : qs
scanr1 f [] = []
scanr1 f [x] = [x]
scanr1 f (x:xs) = f x q : qs
where qs@(q:_) = scanr1 f xs
scanr1 _ [] = errorEmptyList "scanr1"
-- iterate f x returns an infinite list of repeated applications of f to x:
-- iterate f x == [x, f x, f (f x), ...]
...
...
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