summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2006-12-12 17:36:25 +0000
committerIan Lynagh <igloo@earth.li>2006-12-12 17:36:25 +0000
commit22b4135c5e56cfafc066195e02d00d4dc3de6146 (patch)
treea054ca82d15fb6c7d4174cc6fe8316ef64749ee2
parente6e36c2b65e936dc73d57b2f29b7cff84b0cbb4e (diff)
downloadhaskell-22b4135c5e56cfafc066195e02d00d4dc3de6146.tar.gz
Detab
-rw-r--r--utils/nofib-analyse/GenUtils.lhs64
1 files changed, 32 insertions, 32 deletions
diff --git a/utils/nofib-analyse/GenUtils.lhs b/utils/nofib-analyse/GenUtils.lhs
index 8bc9957b0d..fa89d4fda5 100644
--- a/utils/nofib-analyse/GenUtils.lhs
+++ b/utils/nofib-analyse/GenUtils.lhs
@@ -12,7 +12,7 @@
> assocMaybeErr,
> arrElem,
> memoise,
-> returnMaybe,handleMaybe, findJust,
+> returnMaybe,handleMaybe, findJust,
> MaybeErr(..),
> maybeMap,
> joinMaybe,
@@ -25,15 +25,15 @@
> rjustify,
> space,
> copy,
-> combinePairs,
-> --trace, -- re-export it
-> fst3,
-> snd3,
-> thd3
+> combinePairs,
+> --trace, -- re-export it
+> fst3,
+> snd3,
+> thd3
#if __HASKELL1__ < 3 || ( defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 200 )
-> ,Cmp(..), compare, lookup, isJust
+> ,Cmp(..), compare, lookup, isJust
#endif
@@ -174,7 +174,7 @@ Gofer-like stuff:
> space :: Int -> String
> space n | n < 0 = ""
-> | otherwise = copy n ' '
+> | otherwise = copy n ' '
> copy :: Int -> a -> [a] -- make list of n copies of x
> copy n x = take n xs where xs = x:xs
@@ -191,11 +191,11 @@ Gofer-like stuff:
> combinePairs :: (Ord a) => [(a,b)] -> [(a,[b])]
> combinePairs xs =
-> combine [ (a,[b]) | (a,b) <- sortWith (\ (a,_) (b,_) -> a <= b) xs]
+> combine [ (a,[b]) | (a,b) <- sortWith (\ (a,_) (b,_) -> a <= b) xs]
> where
-> combine [] = []
-> combine ((a,b):(c,d):r) | a == c = combine ((a,b++d) : r)
-> combine (a:r) = a : combine r
+> combine [] = []
+> combine ((a,b):(c,d):r) | a == c = combine ((a,b++d) : r)
+> combine (a:r) = a : combine r
>
#if __HASKELL1__ < 3 || ( defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL__ < 200 )
@@ -209,12 +209,12 @@ Gofer-like stuff:
> data Cmp = LT | EQ | GT
> compare a b | a < b = LT
-> | a == b = EQ
-> | otherwise = GT
+> | a == b = EQ
+> | otherwise = GT
> isJust :: Maybe a -> Bool
> isJust (Just _) = True
-> isJust _ = False
+> isJust _ = False
#endif
@@ -263,34 +263,34 @@ will give a very efficent variation of the fib function.
> (b'', x') = f b' x
> (b', xs') = mapAccumR f b xs
-> 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 :: (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
+> (b', x') = f b x
+> (b'', xs') = mapAccumL f b' xs
Here is the bi-directional version ...
> 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 accumulator and result list
+> -- 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 accumulator 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
+> (a',b'',y) = f a b' x
+> (a'',b',ys) = mapAccumB f a' b xs
> assert False x = error "assert Failed"