A slice consisting of non-consecutive elements of an array?
forkit
forkit at gmail.com
Wed Jan 12 05:27:08 UTC 2022
I am familiar with the concept of a slice in D.
However, a slice is a consecutive slice, is in not? (e.g) [4..$-1]
I would like a slice (or a view, or whatever name you wanna call
it), of particular elements within an array that may not be
consecutive. e.g. [4-7,8,10,13-16]
Consider below:
I want a slice/view on this array that only contains elements
with the string "one".
["one", "one", "two", "one", "two", "one", "one", "two]
Most importantly, I do NOT want to allocate - so the slice/view
needs to be 'referencing' existing data (not copying it).
Yes, I can hard code it, C style. I already know this.
Does phobos offer something like this?
More information about the Digitalmars-d-learn
mailing list