module S11 ( -- * Exercises 1, 2, 3, 5, and 6 -- | See <../pdfs/11.pdf>. -- * Exercise 4 lengthConcat, -- ** An alternative implementation using @foldl@ lengthConcat' ) where lengthConcat :: [[a]] -> Int lengthConcat xs = go 0 xs where go acc [] = acc go acc (x:xs) = go (len 0 x + acc) xs where len acc [] = acc len acc (x:xs) = len (acc + 1) xs lengthConcat' :: [[a]] -> Int lengthConcat' = foldl addLen 0 where addLen = foldl (flip $ const (+1))