Selected elements from splitter output

Chris Piker chris at hoopjump.com
Tue May 4 20:40:08 UTC 2021


Hi D

I have a white-space delimited file with quite a few columns, but 
I only care about columns 0, 2, 3, 4, 8, 9, 10.  Since I don't 
need most of the 60+ columns it seemed like:

    std.algorithm.iteration.splitter()

would be a better function to use then std.array.split().  My 
problem is that I don't know how to get the elements I care about 
from the splitter, for example:

char[] line;
char[][] cols_needed;
while(file.readln(line)){
    auto a = line.splitter()
    cols_needed = ???
}

On a related note, are there any standard library functions that 
select specific elements of a range by index without a loop?  So 
the logical equivalent of:

auto string_range
char[][] wanted = string_range.get( [1, 5, 7] );  // pseudo-code 
element selection

It's not a big deal if there's not something standard.

Thanks for the help,



More information about the Digitalmars-d-learn mailing list