Skip to content

Commit

Permalink
Extract the larger/smaller predicates.
Browse files Browse the repository at this point in the history
  • Loading branch information
robrix committed Jul 5, 2020
1 parent aa45795 commit cc480af
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Data/IntervalSet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ insert new set
Just l
| l `isSubintervalOf` new -> new <| gt
| sup l < inf new -> lt >< new <| gt
| otherwise -> case split smaller lt of
| otherwise -> case split (smaller new) lt of
(lt', t) -> lt' >< maybe new (union new) (measure t) <| gt
where
(lt, gt) = split larger set
larger = maybe False ((> sup new) . sup)
smaller = maybe False ((<= inf new) . sup)
(lt, gt) = split (larger new) set

larger, smaller :: Ord a => Interval I a -> Maybe (Interval I a) -> Bool
larger new = maybe False ((> sup new) . sup)
smaller new = maybe False ((<= inf new) . sup)

0 comments on commit cc480af

Please sign in to comment.