4 ms·
Is it just me but I never use recursion in JS (or imperative languages generally) and it never really comes up as a need?
by quickthrower2 3y ago
Is it just me but I never use recursion in JS (or imperative languages generally) and it never really comes up as a need?
- jiehong 3y agoWe’re using recursion at $company to validate user inputs because it’s a user-defined tree of unknown depth.
- anonymoushn 3y agoFor example if you write a json deserializer that's generic over the struct you want to deserialize to (or one in JS that returns a JS object), you'll usually use some sort of recursion. My generic radix sort[0] also has recursion in it, which seems like the most straightforward way to write it, but of course any recursive function could be mechanically converted to one that does not use recursion. [0]: https://github.com/alichraghi/zort/blob/main/src/radix.zig#L140 https://github.com/alichraghi/zort/blob/main/src/radix.zig#L...
- odyssey7 3y agoNitpick: JS is multi-paradigm.
- quickthrower2 3y agoYeah I should have been more specific. I mean languages where recursion is idiomatic for many problems because the language is purely functional like Haskell.