[add rewrite rules and improved efficiency of some routines in GenUtil
John Meacham <john@repetae.net>**20050930030344] hunk ./GenUtil.hs 110
-import List(group,sort)
-import List(intersperse, sortBy, groupBy, transpose)
+import List
hunk ./GenUtil.hs 121
+{-# RULES "snub/snub" forall x . snub (snub x) = snub x #-}
+{-# RULES "snub/nub" forall x . snub (nub x) = snub x #-}
+{-# RULES "nub/snub" forall x . nub (snub x) = snub x #-}
+{-# RULES "snub/sort" forall x . snub (sort x) = snub x #-}
+{-# RULES "sort/snub" forall x . sort (snub x) = snub x #-}
+{-# RULES "snub/[]" snub [] = [] #-}
+{-# RULES "snub/[x]" forall x . snub [x] = [x] #-}
+
hunk ./GenUtil.hs 162
+minimumUnder _ [x] = x
hunk ./GenUtil.hs 172
+maximumUnder _ [x] = x
hunk ./GenUtil.hs 272
+{-# RULES "replicateM/0" replicateM 0 = const (return []) #-}
+{-# RULES "replicateM_/0" replicateM_ 0 = const (return ()) #-}
+
hunk ./GenUtil.hs 364
-chunk mw s | length s < mw = [s]
-chunk mw s = case splitAt mw s of (a,b) -> a : chunk mw b
+chunk 0 _  = repeat []
+chunk _ [] = []
+chunk mw s = case splitAt mw s of
+    (a,[]) -> [a]
+    (a,b) -> a : chunk mw b
hunk ./GenUtil.hs 520
-count f = length . filter f
+count f xs = g 0 xs where
+    g n [] = n
+    g n (x:xs)
+        | f x = let x = n + 1 in x `seq` g x xs
+        | otherwise = g n xs