I suppose that algorithm lowerBound() and uppperBound() come from C++, but the Nim documentation explains in the opposite way.
https://nim-lang.org/docs/algorithm.html#lowerBound%2CopenArray%5BT%5D%2CK%2Cproc%28T%2CK%29 says:
proc lowerBound > ... Returns a position to the first element in the a that is greater than key,
proc upperBound > ... Returns a position to the first element in the a that is not less (i.e. greater or equal to) than key,
I wonder if they are opposite. They actually work like opposite.
var x = [10, 20, 30, 30, 30, 40, 50]
dump collect(newSeq, for i, v in x: (i, v))
dump lowerBound(x, 30)
dump upperBound(x, 30)
collect(newSeq, for i, v in x:
(i, v)) = @[(0, 10), (1, 20), (2, 30), (3, 30), (4, 30), (5, 40), (6, 50)]
lowerBound(x, 30) = 2
upperBound(x, 30) = 5
Could this be a documentation error?