projects
/
ghc-base.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2d71d3f
)
Add a more efficient Data.List.foldl' for GHC (from GHC's utils/Util.lhs)
author
Ian Lynagh
<igloo@earth.li>
Fri, 6 Jul 2007 20:55:26 +0000
(20:55 +0000)
committer
Ian Lynagh
<igloo@earth.li>
Fri, 6 Jul 2007 20:55:26 +0000
(20:55 +0000)
Data/List.hs
patch
|
blob
|
history
diff --git
a/Data/List.hs
b/Data/List.hs
index
b6a847b
..
32013e9
100644
(file)
--- a/
Data/List.hs
+++ b/
Data/List.hs
@@
-871,8
+871,14
@@
unfoldr f b =
-- | A strict version of 'foldl'.
foldl' :: (a -> b -> a) -> a -> [b] -> a
-- | A strict version of 'foldl'.
foldl' :: (a -> b -> a) -> a -> [b] -> a
+#ifdef __GLASGOW_HASKELL__
+foldl' f z xs = lgo z xs
+ where lgo z [] = z
+ lgo z (x:xs) = let z' = f z x in z' `seq` lgo z' xs
+#else
foldl' f a [] = a
foldl' f a (x:xs) = let a' = f a x in a' `seq` foldl' f a' xs
foldl' f a [] = a
foldl' f a (x:xs) = let a' = f a x in a' `seq` foldl' f a' xs
+#endif
#ifdef __GLASGOW_HASKELL__
-- | 'foldl1' is a variant of 'foldl' that has no starting value argument,
#ifdef __GLASGOW_HASKELL__
-- | 'foldl1' is a variant of 'foldl' that has no starting value argument,