I have one file with a lot of numeric data... and I need to sum all that data...

That is my actual code:

module main;

import std.stdio;
import std.file;
import std.conv : to;

int main(string[] args)
{
        auto f = File("oi.txt");
        auto r = f.byLine();

        auto tot = 0;
        foreach(line;r)
        {
                if(line[0] == '1')
                        tot += to!int(line[253..266]);
        }

        writeln(tot);
        return 0;
}

I want to know if have a more better way to make this... maybe using lambda or tamplates....

Reply via email to