sodiray / radash

Functional utility library - modern, simple, typed, powerful
https://radash-docs.vercel.app
MIT License
4.18k stars 167 forks source link

Why is the range function max inclusive? #331

Open JamzOJamz opened 1 year ago

JamzOJamz commented 1 year ago

Why is the range function in Radash max inclusive rather than max exclusive? The docs say that the function is a hat tip to the Python implementation by the same name, so why don’t they function identically? It makes it hard to iterate over an array without making the max value arr.length - 1.

Am I missing something in the docs? Any guidance would be much appreciated :)

torgesla commented 11 months ago

Totally agree. This unexpected API-issue does of course apply to radash.list as well. When a single parameter is passed, it is named size in the documentation, but the actual size / length of the iterator returned is one more than the number passed as size-parameter. image

aleclarson commented 1 month ago

Hello @JamzOJamz and @torgesla, we'd be open to fixing this over at the Radashi fork, if either of you want to champion the effort. Of course, it's a breaking change, so please target the next branch with your PR.