Error: variable i cannot be read at compile time

Vino vino.bheeman at hotmail.com
Thu Jan 4 16:51:33 UTC 2018


Hi All,

  Request your help on the below error for the below program.

Error:
CReadCol.d(20): Error: variable i cannot be read at compile time
CReadCol.d(21): Error: variable i cannot be read at compile time
CReadCol.d(22): Error: variable i cannot be read at compile time


Program
import std.algorithm: joiner, sort, countUntil, uniq;
import std.container.array;
import std.csv: csvReader;
import std.stdio: File, writeln;
import std.typecons: Tuple, tuple;

auto read () {
Array!string Ucol1, Ucol2;
Array!int Ucol3;
int rSize;
auto file = 
File("C:\\Users\\bheev1\\Desktop\\Current\\Script\\Others\\ColRead.csv", "r");
foreach (record; 
file.byLineCopy.joiner("\n").csvReader!(Tuple!(string, string, 
int)))
{ Ucol1.insertBack(record[0]); Ucol2.insertBack(record[1]); 
Ucol3.insertBack(record[2]); rSize = record.length; }
return tuple(Ucol1, Ucol2, Ucol3, rSize);
}
/***********************************************************************************/
auto Master (int Size) {
Array!int Keycol;
for(int i = 0; i < Size; i++) {
typeof(read()[i]) Datacol;
Datacol.insertBack(sort(read[i].dup[]).uniq);
foreach(k; read[i]) { Keycol.insertBack(Datacol[].countUntil(k)); 
} }
return tuple (Datacol[], Keycol[]);
}

void main () {
int Size = read[3];
writeln(Master(Size));
}

From,
Vino.B


More information about the Digitalmars-d-learn mailing list