Re: ranges reading garbage

2015-02-16 Thread anonymous via Digitalmars-d-learn
On Sunday, 15 February 2015 at 22:38:20 UTC, anonymous wrote: And more: import std.stdio; struct MapResult(alias fun) { @property int front() {return fun();} @property auto save() {return typeof(this)();} } void main() { int ys_length = 4; auto dg = {return MapResult!({return ys_

Re: ranges reading garbage

2015-02-15 Thread anonymous via Digitalmars-d-learn
On Sunday, 15 February 2015 at 19:54:45 UTC, anonymous wrote: 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); } And more: import std.stdio;

Re: ranges reading garbage

2015-02-15 Thread anonymous via Digitalmars-d-learn
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, xB

Re: ranges reading garbage

2015-02-15 Thread bearophile via Digitalmars-d-learn
FG: Odd... Still something is wrong. It prints: [0, 4, 5, 1, 1, 5, 6, 2, 2, 6, 7, 3, 4, 8, 9, 5, 5, 5, 6, 6, 6, 6, 7, 7] instead of this: [0, 4, 5, 1, 1, 5, 6, 2, 2, 6, 7, 3, 4, 8, 9, 5, 5, 9, 10, 6, 6, 10, 11, 7] This is less lazy and gives another result: import std.range, std.algorithm

Re: ranges reading garbage

2015-02-15 Thread John Colvin via Digitalmars-d-learn
On Sunday, 15 February 2015 at 18:43:35 UTC, bearophile wrote: John Colvin: 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 chan

Re: ranges reading garbage

2015-02-15 Thread FG via Digitalmars-d-learn
On 2015-02-15 at 19:43, bearophile wrote: void foo(in float[] data, in float[] xs, in float[] ys) @safe { iota(0, data.length, ys.length) .map!(xBase => iota(xBase, xBase + ys.length - 1) .map!(y => [y, y+ys.length, y+ys.length+1, y+1]) .joiner)

Re: ranges reading garbage

2015-02-15 Thread bearophile via Digitalmars-d-learn
John Colvin: 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. Try to replace the only() with: [y, y+ys.leng

ranges reading garbage

2015-02-15 Thread John Colvin via Digitalmars-d-learn
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 =>