why does this error out?

steven kladitis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Nov 9 20:29:36 PST 2015


void main() {
     import std.stdio, std.algorithm, std.range, std.conv;

     enum digSum = (int n) => n.text.map!(d => d - '0').sum;
//    enum harshads = iota(1, int.max).filter!(n => n % digSum(n) 
== 0);
     enum harshads = iota(1, 256).filter!(n => n % digSum(n) == 0);
     harshads.take(20).writeln;
     harshads.filter!(h => h > 1000).front.writeln;
}

// this compiles but always prints 1 number and gets 
object.Error@(0): Access Violation


More information about the Digitalmars-d-learn mailing list