How to collect "some" items of a range in an array?
H. S. Teoh
hsteoh at qfbox.info
Mon Jan 6 19:58:12 UTC 2025
On Mon, Jan 06, 2025 at 07:30:27PM +0000, Renato via Digitalmars-d-learn wrote:
> Is there any Phobos function that collects "some" items of a range
> into an array/slice?
> It's kind of embarrassing that I've been trying to find this for hours
> now without success :(.
[...]
> My use case is to parse a file format where a line is expected to have
> 4 items. I am currently using `takeExactly(4)` but that doesn't let me
> index on it, so I can only think of doing inconvenient (and
> inefficient) stuff like `front, skip(1).front ...` to avoid having to
> write my own `toArray` :D. I couldn't even find a method to take 1
> item and advance the range! Am I just looking at the entirely wrong
> places (std.range, std.algorithm.iteration)??
[...]
What's wrong with just using std.array.array?
T
--
Recently, our IT department hired a bug-fix engineer. He used to work for Volkswagen.
More information about the Digitalmars-d-learn
mailing list