From d2e54ea483bfe057e54ab93b76059dcdfac15f6f Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Sun, 28 Oct 2007 01:22:55 +0000 Subject: [PATCH] Added another helper function to the Utils module --- common/Utils.hs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/Utils.hs b/common/Utils.hs index 9b3f952..0193954 100644 --- a/common/Utils.hs +++ b/common/Utils.hs @@ -21,6 +21,7 @@ with this program. If not, see . module Utils where import Control.Monad +import Data.Ord import System.IO import System.IO.Error import Text.Regex @@ -94,3 +95,10 @@ mapPairs :: (a -> a -> b) -> [a] -> [b] mapPairs _ [] = [] mapPairs _ [x] = [] mapPairs f (x0:(x1:xs)) = (f x0 x1) : (mapPairs f (x1:xs)) + +-- | Given a list of comparisons in order major->minor, returns the resultant ordering +combineCompare :: [Ordering] -> Ordering +combineCompare [] = EQ +combineCompare (LT:_) = LT +combineCompare (GT:_) = GT +combineCompare (EQ:os) = combineCompare os