File.lockingBinaryWriter

Returns an output range that locks the file and allows fast writing to it.

struct File
lockingBinaryWriter
()

Examples

Produce a grayscale image of the Mandelbrot set in binary Netpbm format to standard output.

1 import std.algorithm, std.complex, std.range, std.stdio;
2 
3 void main()
4 {
5     enum size = 500;
6     writef("P5\n%d %d %d\n", size, size, ubyte.max);
7 
8     iota(-1, 3, 2.0/size).map!(y =>
9         iota(-1.5, 0.5, 2.0/size).map!(x =>
10             cast(ubyte)(1+
11                 recurrence!((a, n) => x + y * complex(0, 1) + a[n-1]^^2)(complex(0))
12                 .take(ubyte.max)
13                 .countUntil!(z => z.re^^2 + z.im^^2 > 4))
14         )
15     )
16     .copy(stdout.lockingBinaryWriter);
17 }

Meta

Suggestion Box / Bug Report