Re:Mindset Shifts for Functional Programming
by chriswarbo on Thursday April 06, 2023 @05:50AM
(#35466290)
Yes, exactly :) Again, it's not always "better", but it's a situation that doesn't seem to map directly to a loop.
I gave a more complicated, realistic example in a sibling comment https://news.ycombinator.com/item?id=35466256
> you've changed the semantics and engineering tradeoffs so much that we might as well write `n % 2 == 0`.
That is a fairly glaring weakness of the example you've chosen - it is taking a simple situation and overthinking it. It doesn't really matter because I see your point and surely one would exist, but do you have an example where this technique is an efficient solution?