Why is there no isless(::Int64, ::UnitRange{Int64})?

This is the approach taken by Intervals.jl, yes.

julia> using Intervals

julia> 2 < 3..5
true

julia> 4 ≤ 3..5
false

Although it seems we don’t agree about the meaning of here.

It’s also missing some generic capabilities which would be critical given how I discovered the topic of this thread:

julia> "abcde"[2..3]
MethodError: no method matching getindex(::String, ::Interval{Int64, Closed, Closed})

That one might be worth a PR actually. Not clear if it’s in keeping with the spirit of the package, but it could be rather nice, I’ve wanted the ability to work with semi-open intervals fairly often when doing stringy things.

The question isn’t really about how to code around the lack of an isless here, that’s very straightforward.

I also want to point out that, as I mentioned in a previous post, defaults to a < b || a ==b. So defining isless(i, range) wouldn’t let slip the dogs of war.

1 Like