Implement various standard functions for nullable arrays#1
Open
craigfe wants to merge 2 commits intochambart:masterfrom
Open
Implement various standard functions for nullable arrays#1craigfe wants to merge 2 commits intochambart:masterfrom
craigfe wants to merge 2 commits intochambart:masterfrom
Conversation
cfd4f8c to
0874331
Compare
craigfe
commented
May 5, 2021
| [to_start] and [len] do not designate a valid subarray of [to]. | ||
| *) | ||
|
|
||
| val of_array : 'a array -> 'a t |
Author
There was a problem hiding this comment.
These functions might want to be called of_some_array / of_some_list or some such.
Comment on lines
+244
to
+245
| (* Include an extra element at the start of the new array, | ||
| then set it to [null]. *) |
Author
There was a problem hiding this comment.
I'm not sure whether this trick is actually worthwhile.
Comment on lines
+150
to
+152
| Array.init (n+1) (function | ||
| | 0 -> (null:elt) | ||
| | i -> (Obj.magic (f (i-1)) : elt)) |
Author
There was a problem hiding this comment.
(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
Author
|
Gentle ping @chambart, if you have any spare cycles for a review 🙂 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 :-)