Turns out Matz did me one better natively in the language. There’s a #bsearch aggregate function which just goes through the numbers of a Range or Array and runs a little function against it. It finds the lowest qualifying element in O(log_n) time. Useful because you don’t have to be a FP-sperg and can run the code against some external thing which has all kinds of state.
In my use case I wanted to find text size that is as high as possible but won’t overflow outside of a pixel range, but where the user can change the font and the input text so all kinds of wackiness can go on and doing exact calculation is kind of a pain in the ass.