Chris Cain:

import std.stdio, std.file, std.algorithm, std.conv;

void main() {
        dirEntries("data", "*.out", SpanMode.shallow)
                .map!(e => File(e.name).byLine(KeepTerminator.yes)
                        .map!(l => l.to!string())()
                )()
                .array()
                .nWayUnion()
                .copy(stdout.lockingTextWriter);
}

---

I was certainly surprised to find out that nWayUnion existed in std.algorithm which essentially does the work for me. However, I was more surprised to find out that this does not compile.


With the latest compiler this compiles to me:


import std.stdio, std.file, std.algorithm, std.conv, std.array;

void main() {
    dirEntries(".", "data*.txt", SpanMode.shallow)
    .map!(e => File(e.name).byLine(KeepTerminator.yes).map!text)
    .array
    .nWayUnion
    .copy(stdout.lockingTextWriter);
}



Then at runtime that array() gives me this:


object.Error: Access Violation
----------------
0x0041DC9F in void* gc.gcx.GC.mallocNoSync(uint, uint, uint*)
0x00363297
----------------


Bye,
bearophile

Reply via email to