ranges reading garbage
John Colvin via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Feb 15 10:13:42 PST 2015
Simplified from something bigger:
import std.range, std.algorithm, std.stdio;
void foo(float[] data, float[] xs, float[] ys)
{
auto indices = iota(0, data.length, ys.length)
.map!(xBase =>
iota(xBase, xBase + ys.length - 1)
.map!(y =>
only(y, y+ys.length, y+ys.length+1, y+1))
.joiner())
.joiner();
writeln(indices);
}
void main()
{
foo([1,2,3,4,5,6,7,8],
[0.1,0.2], [10,20,30,40]);
}
prints things like [0, 4, 5, 1, 1, 1459971595, 1459971596, 2, 2,
1459971596, 1459971597, 3, 4, 8, 9, 5, 5, 4441427819, 4441427820,
6, 6, 4441427820, 4441427821, 7] but the output isn't consistent,
the big numbers change on each run.
More information about the Digitalmars-d-learn
mailing list