-
Notifications
You must be signed in to change notification settings - Fork 0
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
mitems with start #579
Comments
but openArray can be sliced (modulo some backend specific bugs, see nim-lang#15952); assuming nim-lang#15952) is fixed, doesnt' |
|
instead of: proc sampleBuffer*[T](r: var Rand, buffer: var openArray[T]; alphabet: set[T]; start = 0.Natural) = ...
sampleBuffer(r, buf, alpha, start = 2) use: proc sampleBuffer*[T](r: var Rand, buffer: var openArray[T]; alphabet: set[T]) = ...
sampleBuffer(r, buf.toOpenArray(2, buf.high), alpha) |
Then this bug is kinda fixed.
|
not sure it belongs to mitems documentation, toOpenarray likewise can be used in other contexts (eg items and plenty other places). But we should definitely fix nim-lang#15952 |
Working on improving the
random.sampleBuffer
, I made this change:I need a
mitems
but that takes astart: Natural
argument, but no such overload exists,would be very nice because
mitems
tends to be used for in-place good performance loops!https://nim-lang.github.io/Nim/iterators.html#mitems.i%2Carray%5BIX%2CT%5D
What if I have a gigabyte sized iterable but only want to iterate only the last 9 items ?.
mitems
that takes 1 extra argumentstart: Natural
.0..9
beingstart..end
, but with thestart
at least is Ok.The code of
mitems
is not massively complex, should be easy to implement.Not only performance, but consistency and correctness of the code,
switching
mitems
withfor i in start..end
and back again is just wrong.The text was updated successfully, but these errors were encountered: