From: malcolm Date: Wed, 6 Jul 2005 16:17:36 +0000 (+0000) Subject: [project @ 2005-07-06 16:17:36 by malcolm] X-Git-Tag: cmm-merge2~64 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=d3547c663c47e38afe6cbe1193beb475fd6e836e;p=haskell-directory.git [project @ 2005-07-06 16:17:36 by malcolm] Fix (from Scott Turner) for a broken implementation of 'split'. --- diff --git a/Data/IntMap.hs b/Data/IntMap.hs index 972c2e7..ff9d30b 100644 --- a/Data/IntMap.hs +++ b/Data/IntMap.hs @@ -798,6 +798,7 @@ split :: Key -> IntMap a -> (IntMap a,IntMap a) split k t = case t of Bin p m l r + | nomatch k p m -> if k>p then (t,Nil) else (Nil,t) | zero k m -> let (lt,gt) = split k l in (lt,union gt r) | otherwise -> let (lt,gt) = split k r in (union l lt,gt) Tip ky y @@ -812,6 +813,7 @@ splitLookup :: Key -> IntMap a -> (IntMap a,Maybe a,IntMap a) splitLookup k t = case t of Bin p m l r + | nomatch k p m -> if k>p then (t,Nothing,Nil) else (Nil,Nothing,t) | zero k m -> let (lt,found,gt) = splitLookup k l in (lt,found,union gt r) | otherwise -> let (lt,found,gt) = splitLookup k r in (union l lt,found,gt) Tip ky y