On Thursday, 6 November 2014 at 22:40:58 UTC, John Colvin wrote:
this should be a textbook case for std.range.transposed, but I
can't seem to get it to work.
Ah, I didn't know this existed. Apparently it's not yet released,
that's why it's not in the official documentation.
With DMD and
Marc Schütz:
auto sums = input
.transposed
.map!(a = a.sum);
And that part is better written:
.map!sum;
I also suggest to align the leading dot to the precedent line:
auto sums = input
.transposed
On Friday, 7 November 2014 at 10:58:58 UTC, Marc Schütz wrote:
On Thursday, 6 November 2014 at 22:40:58 UTC, John Colvin wrote:
this should be a textbook case for std.range.transposed, but I
can't seem to get it to work.
Ah, I didn't know this existed. Apparently it's not yet
released,
I have rectangular forward range of forward ranges (not arrays):
[
[a11, a12, ... a1N],
[a21, a22, ... a2N],
...
[aM1, aM2, ... aMN]
]
I need lazy forward range:
[
a11 + a21 + ... aM1,
a12 + a22 + ... aM2,
...
a1N + a2N + ... aMN
]
Range of sum elements of every columns;
M, N -
On Thursday, 6 November 2014 at 15:53:27 UTC, Jack Applegame
wrote:
I have rectangular forward range of forward ranges (not arrays):
[
[a11, a12, ... a1N],
[a21, a22, ... a2N],
...
[aM1, aM2, ... aMN]
]
I need lazy forward range:
[
a11 + a21 + ... aM1,
a12 + a22 + ... aM2,
...
a1N +
On Thu, 06 Nov 2014 16:57:48 +, Marc Schütz wrote:
On Thursday, 6 November 2014 at 15:53:27 UTC, Jack Applegame wrote:
I have rectangular forward range of forward ranges (not arrays):
[
[a11, a12, ... a1N],
[a21, a22, ... a2N],
...
[aM1, aM2, ... aMN]
]
I need lazy forward
On Thu, 06 Nov 2014 17:08:23 +, Justin Whear wrote:
I think the correct solution
will make use of std.range.frontTraversal, but it will be a bit more
complex due to needing to sum every column. std.range.traversal would
make it easy, but it requires random access.
That should be
On Thursday, 6 November 2014 at 16:57:50 UTC, Marc Schütz wrote:
On Thursday, 6 November 2014 at 15:53:27 UTC, Jack Applegame
wrote:
I have rectangular forward range of forward ranges (not
arrays):
[
[a11, a12, ... a1N],
[a21, a22, ... a2N],
...
[aM1, aM2, ... aMN]
]
I need lazy forward
On Thursday, 6 November 2014 at 17:08:23 UTC, Justin Whear wrote:
This would sum along the wrong dimension. I think the correct
solution
will
make use of std.range.frontTraversal, but it will be a bit more
complex
due to
needing to sum every column. std.range.traversal would make it
easy,
On 11/06/14 18:32, bearophile via Digitalmars-d-learn wrote:
Marc Schütz:
We'd need something taking and returning a RoR that mirrors them
diagonally. Then we could simply apply `map!(r = r.sum)` on the result.
A simple solution is to create a row of values, and then sum them correctly
void popFront() { foreach (ref r; rr) r.popFront(); }
I think it should be
void popFront() { foreach (ref r; rr.save) r.popFront(); }
but I think OP wanted a ready-made phobos solution, w/o all the
range boilerplate...
exactly.
On Thursday, 6 November 2014 at 15:53:27 UTC, Jack Applegame
wrote:
I have rectangular forward range of forward ranges (not arrays):
[
[a11, a12, ... a1N],
[a21, a22, ... a2N],
...
[aM1, aM2, ... aMN]
]
I need lazy forward range:
[
a11 + a21 + ... aM1,
a12 + a22 + ... aM2,
...
a1N +
On Thursday, 6 November 2014 at 15:53:27 UTC, Jack Applegame
wrote:
I have rectangular forward range of forward ranges (not arrays):
[
[a11, a12, ... a1N],
[a21, a22, ... a2N],
...
[aM1, aM2, ... aMN]
]
I need lazy forward range:
[
a11 + a21 + ... aM1,
a12 + a22 + ... aM2,
...
a1N +
On Thursday, 6 November 2014 at 22:02:09 UTC, John Colvin wrote:
On Thursday, 6 November 2014 at 15:53:27 UTC, Jack Applegame
wrote:
I have rectangular forward range of forward ranges (not
arrays):
[
[a11, a12, ... a1N],
[a21, a22, ... a2N],
...
[aM1, aM2, ... aMN]
]
I need lazy forward
On Thursday, 6 November 2014 at 15:53:27 UTC, Jack Applegame
wrote:
I have rectangular forward range of forward ranges (not arrays):
[
[a11, a12, ... a1N],
[a21, a22, ... a2N],
...
[aM1, aM2, ... aMN]
]
I need lazy forward range:
[
a11 + a21 + ... aM1,
a12 + a22 + ... aM2,
...
a1N +
15 matches
Mail list logo