[Haskell] Data.Map missing keysFM_GE, eltsFM_GE?

Tomasz Zielonka tomasz.zielonka at gmail.com
Mon Feb 21 16:05:02 EST 2005


On Mon, Feb 21, 2005 at 02:39:54PM -0500, S. Alexander Jacobson wrote:
> Data.FiniteMap has functions keysFM_GE and eltsFM_GE which return the 
> keys or elts of pairs greater than or equal to the provided key.
> 
> These functions do not appear to be in the new Data.Map.
> 
> Is this intentional?

There is

    splitLookup :: (Ord k) =>
                   k
                   -> Data.Map.Map k a
                   -> (Data.Map.Map k a, Maybe a, Data.Map.Map k a)

and
    
    toAscList :: Data.Map.Map k a -> [(k, a)]

so you can write keysFM_GE and eltsFM_GE yourself, for example:

  eltsFM_GE k m = maybe [] return eq ++ Prelude.map snd (toAscList ge)
    where
      (_, eq, ge) = splitLookup k m in 

Best regards
Tomasz


More information about the Haskell mailing list