{-# OPTIONS -fno-implicit-prelude #-}
-----------------------------------------------------------------------------
---
+-- |
-- Module : Data.List
-- Copyright : (c) The University of Glasgow 2001
-- License : BSD-style (see the file libraries/core/LICENSE)
-- Stability : provisional
-- Portability : portable
--
--- $Id: List.hs,v 1.2 2001/12/21 15:07:21 simonmar Exp $
---
-- Operations on lists.
--
-----------------------------------------------------------------------------
, 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]
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