Compute in one pass 3 tokens position

Jesse Phillips Jessekphillips+D at gmail.com
Fri May 4 10:40:32 PDT 2012


On Monday, 30 April 2012 at 12:53:16 UTC, bioinfornatics wrote:
> Hi,
> I would like to know how compute in on pass 3 tokens position 
> in a
> sequence.
> curently i do:
> File f = File( "reader.d", "r" );
> scope(exit) f.close();
> char[1024] buffer;
> char[] content = f.rawRead(buffer);
> char[sizediff_t] token = ['(', '{', ';'];
> auto position = map!( a => content.countUntil( a ) )( [ ['('], 
> ['{'],
> [';'] ] );
>
>
> if i use reduce instead map the build fail

It doesn't give your answer directly, but I requested that 
countUntil take ranges:

http://d.puremagic.com/issues/show_bug.cgi?id=5507

And made such a countUntil so that I could use it:

https://github.com/JesseKPhillips/JPDLibs/blob/csvoptimize/csv/newadds.d


More information about the Digitalmars-d-learn mailing list