-- | keep only minimal elements
keepMins :: (a -> a -> Bool) -> [a] -> [a]
keepMins lt l = case l of
    [] -> []
    x : r -> let s = filter (not . lt x) r
                 m = keepMins lt s
              in if any (`lt` x) s then m
                 else x : m

{- |
  A function inspired by the perl function split. A list is splitted
  on a separator element in smaller non-empty lists.
  The separator element is dropped from the resulting list.
-}
keepMins :: (a -> a -> Bool) -> [a] -> [a]
keepMins lt l = case l of
    [] -> []
    x : r -> let s = filter (not . lt x) r
                 m = keepMins lt s
              in if any (`lt` x) s then m
                 else x : m

{- |
  A function inspired by the perl function split. A list is splitted
  on a separator element in smaller non-empty lists.
  The separator element is dropped from the resulting list.
-}
keepMins lt l = case l of
    [] -> []
    x : r -> let s = filter (not . lt x) r
                 m = keepMins lt s
              in if any (`lt` x) s then m
                 else x : m

{- |
  A function inspired by the perl function split. A list is splitted
  on a separator element in smaller non-empty lists.
  The separator element is dropped from the resulting list.
-}