diff options
author | Ian Lynagh <igloo@earth.li> | 2007-07-02 12:26:51 +0000 |
---|---|---|
committer | Ian Lynagh <igloo@earth.li> | 2007-07-02 12:26:51 +0000 |
commit | 262c142b90c94ca1aa577c950a6ceae1f255e2d6 (patch) | |
tree | e1de9880b055869186693df6bb93928c1272f944 /compiler/utils | |
parent | 00c8fa011bed11d95016c13a75e93bc94a4f6aa5 (diff) | |
download | haskell-262c142b90c94ca1aa577c950a6ceae1f255e2d6.tar.gz |
Remove mapAccumL, mapAccumR, mapAccumB
mapAccumL and mapAccumR are in Data.List now.
mapAccumB is unused.
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/ListSetOps.lhs | 4 | ||||
-rw-r--r-- | compiler/utils/Util.lhs | 57 |
2 files changed, 2 insertions, 59 deletions
diff --git a/compiler/utils/ListSetOps.lhs b/compiler/utils/ListSetOps.lhs index becf9e6da2..29f4bb15f8 100644 --- a/compiler/utils/ListSetOps.lhs +++ b/compiler/utils/ListSetOps.lhs @@ -24,9 +24,9 @@ module ListSetOps ( import Outputable import Unique ( Unique ) import UniqFM ( eltsUFM, emptyUFM, addToUFM_C ) -import Util ( isn'tIn, isIn, mapAccumR, sortLe ) +import Util ( isn'tIn, isIn, sortLe ) -import Data.List ( partition ) +import Data.List \end{code} diff --git a/compiler/utils/Util.lhs b/compiler/utils/Util.lhs index abde6d65e6..1d7f7a4ee2 100644 --- a/compiler/utils/Util.lhs +++ b/compiler/utils/Util.lhs @@ -32,7 +32,6 @@ module Util ( transitiveClosure, -- accumulating - mapAccumL, mapAccumR, mapAccumB, foldl2, count, all2, takeList, dropList, splitAtList, split, @@ -488,62 +487,6 @@ transitiveClosure succ eq xs %* * %************************************************************************ -@mapAccumL@ behaves like a combination -of @map@ and @foldl@; -it applies a function to each element of a list, passing an accumulating -parameter from left to right, and returning a final value of this -accumulator together with the new list. - -\begin{code} -mapAccumL :: (acc -> x -> (acc, y)) -- Function of elt of input list - -- and accumulator, returning new - -- accumulator and elt of result list - -> acc -- Initial accumulator - -> [x] -- Input list - -> (acc, [y]) -- Final accumulator and result list - -mapAccumL f b [] = (b, []) -mapAccumL f b (x:xs) = (b'', x':xs') where - (b', x') = f b x - (b'', xs') = mapAccumL f b' xs -\end{code} - -@mapAccumR@ does the same, but working from right to left instead. Its type is -the same as @mapAccumL@, though. - -\begin{code} -mapAccumR :: (acc -> x -> (acc, y)) -- Function of elt of input list - -- and accumulator, returning new - -- accumulator and elt of result list - -> acc -- Initial accumulator - -> [x] -- Input list - -> (acc, [y]) -- Final accumulator and result list - -mapAccumR f b [] = (b, []) -mapAccumR f b (x:xs) = (b'', x':xs') where - (b'', x') = f b' x - (b', xs') = mapAccumR f b xs -\end{code} - -Here is the bi-directional version, that works from both left and right. - -\begin{code} -mapAccumB :: (accl -> accr -> x -> (accl, accr,y)) - -- Function of elt of input list - -- and accumulator, returning new - -- accumulator and elt of result list - -> accl -- Initial accumulator from left - -> accr -- Initial accumulator from right - -> [x] -- Input list - -> (accl, accr, [y]) -- Final accumulators and result list - -mapAccumB f a b [] = (a,b,[]) -mapAccumB f a b (x:xs) = (a'',b'',y:ys) - where - (a',b'',y) = f a b' x - (a'',b',ys) = mapAccumB f a' b xs -\end{code} - A strict version of foldl. \begin{code} |