Conversation
Notices
-
Embed this notice
iced depresso (icedquinn@blob.cat)'s status on Monday, 25-Sep-2023 15:16:23 JST iced depresso
@NEETzsche i think i've done something like that in Nim. though i wouldn't call it "range" since it seems to be a binary search tool.
though i usually would hold off on that too until you've run in to a couple of instances where you actually needed to reuse the same code.-
Embed this notice
NEETzsche (neetzsche@iddqd.social)'s status on Monday, 25-Sep-2023 15:16:21 JST NEETzsche
That’s a native class in Ruby. I’m fixing it because I found a really funny bug right off the bat.
-
Embed this notice
NEETzsche (neetzsche@iddqd.social)'s status on Monday, 25-Sep-2023 15:25:49 JST NEETzsche
This is kind of a shitpost to begin with. But in Ruby, you can just “open up” existing classes and add shit to them. I wanted a #bisect_left and #bisect_right method to take the left and right halves of a “Range.” My riff, which was tongue-in-cheek, was that if this were JavaScript I’d release this as a gem (library) on its own
-
Embed this notice
NEETzsche (neetzsche@iddqd.social)'s status on Monday, 25-Sep-2023 15:32:29 JST NEETzsche
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.
-
Embed this notice
iced depresso (icedquinn@blob.cat)'s status on Monday, 25-Sep-2023 15:32:30 JST iced depresso
@NEETzsche yes and there are times that micropackages are fine
-
Embed this notice