Understanding issorted's lt keyword

I think I see the pattern you are following, but ultimately issorted is likely to be the wrong concept, since you’re not asking if a list is sorted, but you’re asking if it’s strictly increasing. I think you should think of issorted as a verifier for sort. There’s nothing that sort can do to make some data strictly increasing and still look like a sort (it would have to e.g. discard some data).

Consider something instead like:

julia> using IterTools: partition

julia> all_consecutive_pairs(pred, itr) = all(Base.splat(pred), partition(itr, 2, 1))
all_consecutive_pairs (generic function with 1 method)

julia> all_consecutive_pairs(<, [1, 2, 3])
true

julia> all_consecutive_pairs(<, [1, 3, 3])
false
2 Likes