X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FList.hs;h=2a37187899045ffd11198db16aa80c76f5d99d1a;hb=9fa9bc17072a58c0bae2cce4764d38677e96ac29;hp=9082db586a6c279b8e4ed0297548bc9a2770bd42;hpb=260e7f2ed9a43c6ecf5a556d77817f39ed2893ab;p=ghc-base.git diff --git a/Data/List.hs b/Data/List.hs index 9082db5..2a37187 100644 --- a/Data/List.hs +++ b/Data/List.hs @@ -1,6 +1,6 @@ {-# OPTIONS -fno-implicit-prelude #-} ----------------------------------------------------------------------------- --- +-- | -- Module : Data.List -- Copyright : (c) The University of Glasgow 2001 -- License : BSD-style (see the file libraries/core/LICENSE) @@ -9,7 +9,7 @@ -- Stability : provisional -- Portability : portable -- --- $Id: List.hs,v 1.2 2001/12/21 15:07:21 simonmar Exp $ +-- $Id: List.hs,v 1.4 2002/04/24 16:31:39 simonmar Exp $ -- -- Operations on lists. -- @@ -90,6 +90,7 @@ module Data.List , length -- :: [a] -> Int , (!!) -- :: [a] -> Int -> a , foldl -- :: (a -> b -> a) -> a -> [b] -> a + , foldl' -- :: (a -> b -> a) -> a -> [b] -> a , foldl1 -- :: (a -> a -> a) -> [a] -> a , scanl -- :: (a -> b -> a) -> a -> [b] -> [a] , scanl1 -- :: (a -> a -> a) -> [a] -> [a] @@ -521,6 +522,14 @@ unfoldr f b = Just (a,new_b) -> a : unfoldr f new_b Nothing -> [] + +-- ----------------------------------------------------------------------------- +-- strict version of foldl + +foldl' :: (a -> b -> a) -> a -> [b] -> a +foldl' f a [] = a +foldl' f a (x:xs) = let a' = f a x in a' `seq` foldl' f a' xs + -- ----------------------------------------------------------------------------- -- List sum and product