Replies: 1 comment
-
|
Hi! :) For |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have just recently started playing around with Containers (and OCaml in general) and have found a few improvements I would consider for the range functions and their operators. I have already submitted #480 to fix some comments around these areas, but have some more ideas that I'd like to get an approval for before developing them into pull requests. (They currently lack tests, documentation, etc.)
Stepped range for
SeqI have implemented a range function (actually, two versions) for Seq that supports setting the step size. I wonder if this would be something that could be considered for inclusion in the library, and if so, which version would be preferred?
(Now that I think about it, it might even make sense to have stepped ranges for infinite sequences as well. 🤔)
Operator for stepped ranges
While using the previously mentioned functions I came up with a way to fake a "ternary" operator by accepting a tuple as its first argument. After implementing it for myself I have realized that there was precedent for such an operator in Batteries, implemented using the exact same trick, just with a different symbol. Sticking to their notation, it could be implemented as:
After a while I have also noticed the existence of
CCList.range_by, which could use a similar operator form as well.In case we'd really like to cover everything,
--.^could be added too.PS. I also have some ideas around refactoring existing code, but this has already became quite a long post, so I'll wait for feedback before adding more of my thoughts.
Beta Was this translation helpful? Give feedback.
All reactions