Untitled attachment
https://media.iddqd.social/media/bff25155f37adccffe4ad217dcdc9fc7cc73bdcb99d16645a8e9acc340f9426f.png
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.
GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.
All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.