Thread overview | ||||||
---|---|---|---|---|---|---|
|
January 27, 2014 std.copy (to multiple output ranges), | ||||
---|---|---|---|---|
| ||||
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? |
January 27, 2014 Re: std.copy (to multiple output ranges), | ||||
---|---|---|---|---|
| ||||
Posted in reply to Robert Schadek | 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. |
January 27, 2014 Re: std.copy (to multiple output ranges), | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ilya Yaroshenko | 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:
>> 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.
If you need duplicates: a.copy(b).copy(c).copy(d) ...
|
January 27, 2014 Re: std.copy (to multiple output ranges), | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ilya Yaroshenko | On 01/27/2014 07:36 PM, Ilya Yaroshenko wrote: > 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; > } > good idea but does not work, this fills every array with 10 elements >> 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. yes this works, I was stupid here |
Copyright © 1999-2021 by the D Language Foundation