Do binary search, pred(l) must be false, pred(r) must be true, and pred must have monotonic
[pred(l) = false, false, ..., false, true, true, ..., pred(r) = true]
minimum x, s.t. pred(x) = true
assert(binSearch!(x => x*x >= 100)(0, 20) == 10); assert(binSearch!(x => x*x >= 101)(0, 20) == 11); assert(binSearch!(x => true)(0, 20) == 1); assert(binSearch!(x => false)(0, 20) == 20);
See Implementation
Do binary search, pred(l) must be false, pred(r) must be true, and pred must have monotonic
[pred(l) = false, false, ..., false, true, true, ..., pred(r) = true]