ranges reading garbage
anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Feb 15 11:54:44 PST 2015
On Sunday, 15 February 2015 at 18:13:44 UTC, John Colvin wrote:
> 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.
Reduced some more:
import std.algorithm, std.stdio;
void main()
{
int ys_length = 4;
auto indices = [0]
.map!(xBase => [0].map!(y => ys_length))
.joiner();
writeln(indices);
}
More information about the Digitalmars-d-learn
mailing list