darcs patch: Add proximal lookup functions in Map (and 2 more)
ross at soi.city.ac.uk
Tue May 22 13:41:47 EDT 2007
On Tue, May 22, 2007 at 10:28:24AM -0700, Adam Langley wrote:
> Please see attached 2 patches (and 1 misc patch) to Data.Map which add
> the ability to lookup entries by proximity. For example, if I have a
> Map which relates times to the state of a system at that time:
> let m = Map.fromList [(1, x), (10, y), (15, z)]
> Then, if I want to find out the state at time 5:
> Map.nearestLesserOrEqual 5 m
> -> (1, x)
> In a similar fashion, nearestGreaterOrEqual and nearest are also provided.
nearest needs Num, but the other two shouldn't.
More information about the Libraries