Re: Using algorithms with ranges

2019-10-03 Thread mipri via Digitalmars-d-learn
On Thursday, 3 October 2019 at 08:52:22 UTC, Andrea Fontana wrote: On Thursday, 3 October 2019 at 05:33:04 UTC, mipri wrote: void main() { import std.range : iota; foreach (x; iota(1, 10).withHistory) writeln(x); } This doesn't work as expected, I think. auto r = iota(1,10).

Re: Using algorithms with ranges

2019-10-03 Thread mipri via Digitalmars-d-learn
On Thursday, 3 October 2019 at 08:52:22 UTC, Andrea Fontana wrote: On Thursday, 3 October 2019 at 05:33:04 UTC, mipri wrote: void main() { import std.range : iota; foreach (x; iota(1, 10).withHistory) writeln(x); } This doesn't work as expected, I think. auto r = iota(1,10).

Re: Using algorithms with ranges

2019-10-03 Thread Andrea Fontana via Digitalmars-d-learn
On Thursday, 3 October 2019 at 05:33:04 UTC, mipri wrote: void main() { import std.range : iota; foreach (x; iota(1, 10).withHistory) writeln(x); } This doesn't work as expected, I think. auto r = iota(1,10).withHistory; writeln(r.front); writeln(r.front);

Re: Using algorithms with ranges

2019-10-02 Thread mipri via Digitalmars-d-learn
On Thursday, 3 October 2019 at 05:20:47 UTC, mipri wrote: It'd be nicer to do compose a range over iota, as in iota(1, 10).newThingWithHistory but I don't know how to do that yet. I guess c.f. std.range.retro This is a bit better: #! /usr/bin/env rdmd import std.stdio; auto withHistory(R

Re: Using algorithms with ranges

2019-10-02 Thread mipri via Digitalmars-d-learn
On Thursday, 3 October 2019 at 04:33:10 UTC, Brett wrote: I routinely have to generate data using points sequentially and refer to previous points in the data set, maybe even search them. I also may have to break up the algorithm in to parts. I'd like to get more in to ranges but I simply do n