-
Notifications
You must be signed in to change notification settings - Fork 1
Implement various standard functions for nullable arrays #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
cfd4f8c to
0874331
Compare
| [to_start] and [len] do not designate a valid subarray of [to]. | ||
| *) | ||
|
|
||
| val of_array : 'a array -> 'a t |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These functions might want to be called of_some_array / of_some_list or some such.
| (* Include an extra element at the start of the new array, | ||
| then set it to [null]. *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure whether this trick is actually worthwhile.
| Array.init (n+1) (function | ||
| | 0 -> (null:elt) | ||
| | i -> (Obj.magic (f (i-1)) : elt)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I'd guess it's more efficient to first create a null array and then set the elements, vs. allocating a closure.)
The `(alias ...)` field on rules requires at least Dune lang 2.0.
0874331 to
70f8ebe
Compare
|
Gentle ping @chambart, if you have any spare cycles for a review 🙂 |
This PR adds some functions that I found useful when porting https://github.com/backtracking/vector to use a nullable array internally.
I haven't yet added tests for these functions beyond just exercising them from within
vector(and so some of them are very likely broken), but I'm happy to do so if you think these functions are a fit for the API. Just let me know :-)