racket / data

Other
16 stars 23 forks source link

(Feature Request) Get the bounds of an interval when referencing an interval-map? #7

Closed cfinegan closed 6 years ago

cfinegan commented 6 years ago

It would be nice to be able to get the bounds of an interval when referencing an interval-map. The syntax might look something like this:

> (define im (make-interval-map '(((5 . 10) . "value"))))
> (define-values (start finish val)
    (interval-map-ref/bounds im 7))
> start
5
> finish
10
> value
"value"
jeapostrophe commented 6 years ago

If you look at the implementation in terms of data/skip-list, I think this is doable. Can you try to make the implementation and see how hard it is?

On Mon, Nov 6, 2017 at 3:07 PM, Conor Finegan notifications@github.com wrote:

It would be nice to be able to get the bounds of an interval when referencing an interval-map. The syntax might look something like this:

(define im (make-interval-map '(((5 . 10) . "value")))) (define-values (start finish val) (interval-map-ref/bounds im 7)) start 5 finish 10 value "value"

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/racket/data/issues/7, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOM-sLzlKVlwHhuvJCBeE86p-j1XRRpks5sz2b_gaJpZM4QTzTq .

-- -=[ Jay McCarthy http://jeapostrophe.github.io ]=- -=[ Associate Professor PLT @ CS @ UMass Lowell ]=- -=[ Moses 1:33: And worlds without number have I created; ]=-

soegaard commented 6 years ago

The function interval-map-ref/bounds does this. Added after this issue?

Maybe the history line "Added in version 1.1 of package data-lib." was supposed to be after interval-map-ref/bounds and not before?