[replace standard list routines in library with more optimized versions. use mergesort by default.
John Meacham <john@repetae.net>**20060124021451] hunk ./lib/List.hs 53
-nub                     =  nubBy (==)
+nub l                   = nub' l [] where
+    nub' [] _		= []
+    nub' (x:xs) ls
+	| x `elem` ls   = nub' xs ls
+	| otherwise     = x : nub' xs (x:ls)
+
+--nub                     =  nubBy (==)
hunk ./lib/List.hs 62
-nubBy eq []             =  []
-nubBy eq (x:xs)         =  x : nubBy eq (filter (\y -> not (eq x y)) xs)
+nubBy eq l              = nubBy' l []
+  where
+    nubBy' [] _		= []
+    nubBy' (y:ys) xs
+       | elem_by eq y xs = nubBy' ys xs
+       | otherwise	 = y : nubBy' ys (y:xs)
+    elem_by :: (a -> a -> Bool) -> a -> [a] -> Bool
+    elem_by _  _ []		=  False
+    elem_by eq y (x:xs)	=  x `eq` y || elem_by eq y xs
+
+--nubBy eq []             =  []
+--nubBy eq (x:xs)         =  x : nubBy eq (filter (\y -> not (eq x y)) xs)
hunk ./lib/List.hs 171
-sortBy cmp              =  foldr (insertBy cmp) []
+sortBy cmp l = mergesort cmp l where
+    mergesort :: (a -> a -> Ordering) -> [a] -> [a]
+    mergesort cmp = mergesort' cmp . map wrap
+
+    mergesort' :: (a -> a -> Ordering) -> [[a]] -> [a]
+    mergesort' cmp [] = []
+    mergesort' cmp [xs] = xs
+    mergesort' cmp xss = mergesort' cmp (merge_pairs cmp xss)
+
+    merge_pairs :: (a -> a -> Ordering) -> [[a]] -> [[a]]
+    merge_pairs cmp [] = []
+    merge_pairs cmp [xs] = [xs]
+    merge_pairs cmp (xs:ys:xss) = merge cmp xs ys : merge_pairs cmp xss
+
+    merge :: (a -> a -> Ordering) -> [a] -> [a] -> [a]
+    merge cmp xs [] = xs
+    merge cmp [] ys = ys
+    merge cmp (x:xs) (y:ys)
+     = case x `cmp` y of
+            GT -> y : merge cmp (x:xs)   ys
+            _  -> x : merge cmp    xs (y:ys)
+
+    wrap :: a -> [a]
+    wrap x = [x]
+
+-- sortBy cmp              =  foldr (insertBy cmp) []
hunk ./lib/Prelude.hs 712
-unlines          =  concatMap (++ "\n")
+unlines [] = []
+unlines (l:ls) = l ++ '\n' : unlines ls
+--unlines          =  concatMap (++ "\n")
hunk ./lib/Prelude.hs 718
-unwords []       =  ""
-unwords ws       =  foldr1 (\w s -> w ++ ' ':s) ws
+unwords []		=  ""
+unwords [w]		= w
+unwords (w:ws)		= w ++ ' ' : unwords ws
+--unwords []       =  ""
+--unwords ws       =  foldr1 (\w s -> w ++ ' ':s) ws
hunk ./lib/Prelude.hs 766
-sum              =  foldl (+) 0
-product          =  foldl (*) 1
+--sum              =  foldl (+) 0
+--product          =  foldl (*) 1
+sum l	= sum' l 0 where
+    sum' []     a = a
+    sum' (x:xs) a = sum' xs (a+x)
+product	l = prod l 1 where
+    prod []     a = a
+    prod (x:xs) a = prod xs (a*x)