From d3547c663c47e38afe6cbe1193beb475fd6e836e Mon Sep 17 00:00:00 2001 From: malcolm Date: Wed, 6 Jul 2005 16:17:36 +0000 Subject: [PATCH] [project @ 2005-07-06 16:17:36 by malcolm] Fix (from Scott Turner) for a broken implementation of 'split'. --- Data/IntMap.hs | 2 ++ 1 file changed, 2 insertions(+) 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 -- 1.7.10.4