digitalmars.D.learn - std.copy (to multiple output ranges),
- Robert Schadek (6/6) Jan 27 2014 I'm searching the docs for something similar to:
- Ilya Yaroshenko (14/22) Jan 27 2014 Hi, I think you need something like this:
- Ilya Yaroshenko (2/26) Jan 27 2014 If you need duplicates: a.copy(b).copy(c).copy(d) ...
- Robert Schadek (3/23) Jan 27 2014 yes this works, I was stupid here
- Justin Whear (6/13) Jan 27 2014 Curiously, copy doesn't implement multiple output ranges. I don't think...
- Robert Schadek (2/15) Jan 27 2014
I'm searching the docs for something similar to: copy(someInputRange, firstOutputRange, secondOutputRange, ....); I know how to write it by hand, but I'm suspecting that something like this is already in phobos. And secondly, is there some function that gives me a forward range to some input range?
Jan 27 2014
On Monday, 27 January 2014 at 17:26:35 UTC, Robert Schadek wrote:I'm searching the docs for something similar to: copy(someInputRange, firstOutputRange, secondOutputRange, ....); I know how to write it by hand, but I'm suspecting that something like this is already in phobos.Hi, I think you need something like this: import std.stdio; import std.algorithm; import std.range; void main() { auto a = new int[10], b = new int[10], c = new int[10]; iota(30).copy(chain(a, b, c)); a.writeln; b.writeln; c.writeln; }And secondly, is there some function that gives me a forward range to some input range?maybe std.array.array? It is generate an array for some input range.
Jan 27 2014
On Monday, 27 January 2014 at 18:36:32 UTC, Ilya Yaroshenko wrote:On Monday, 27 January 2014 at 17:26:35 UTC, Robert Schadek wrote:If you need duplicates: a.copy(b).copy(c).copy(d) ...I'm searching the docs for something similar to: copy(someInputRange, firstOutputRange, secondOutputRange, ....); I know how to write it by hand, but I'm suspecting that something like this is already in phobos.Hi, I think you need something like this: import std.stdio; import std.algorithm; import std.range; void main() { auto a = new int[10], b = new int[10], c = new int[10]; iota(30).copy(chain(a, b, c)); a.writeln; b.writeln; c.writeln; }And secondly, is there some function that gives me a forward range to some input range?maybe std.array.array? It is generate an array for some input range.
Jan 27 2014
On 01/27/2014 07:36 PM, Ilya Yaroshenko wrote:On Monday, 27 January 2014 at 17:26:35 UTC, Robert Schadek wrote:good idea but does not work, this fills every array with 10 elementsI'm searching the docs for something similar to: copy(someInputRange, firstOutputRange, secondOutputRange, ....); I know how to write it by hand, but I'm suspecting that something like this is already in phobos.Hi, I think you need something like this: import std.stdio; import std.algorithm; import std.range; void main() { auto a = new int[10], b = new int[10], c = new int[10]; iota(30).copy(chain(a, b, c)); a.writeln; b.writeln; c.writeln; }yes this works, I was stupid hereAnd secondly, is there some function that gives me a forward range to some input range?maybe std.array.array? It is generate an array for some input range.
Jan 27 2014
On Mon, 27 Jan 2014 15:44:43 +0100, Robert Schadek wrote:I'm searching the docs for something similar to: copy(someInputRange, firstOutputRange, secondOutputRange, ....); I know how to write it by hand, but I'm suspecting that something like this is already in phobos. And secondly, is there some function that gives me a forward range to some input range?Curiously, copy doesn't implement multiple output ranges. I don't think there's any reason it couldn't. I think an enhancement request is in order. Turning an InputRange into a ForwardRange implies buffering, std.array.array is a general solution.
Jan 27 2014
On 01/27/2014 07:59 PM, Justin Whear wrote:On Mon, 27 Jan 2014 15:44:43 +0100, Robert Schadek wrote:thats what I thoughtI'm searching the docs for something similar to: copy(someInputRange, firstOutputRange, secondOutputRange, ....); I know how to write it by hand, but I'm suspecting that something like this is already in phobos. And secondly, is there some function that gives me a forward range to some input range?Curiously, copy doesn't implement multiple output ranges. I don't think there's any reason it couldn't. I think an enhancement request is in order.Turning an InputRange into a ForwardRange implies buffering, std.array.array is a general solution.
Jan 27 2014