transversal sum

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Nov 6 09:25:56 PST 2014


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, but
> it
> requires random access.

Yeah, I posted to soon. Was surprised that the solution would be 
so easy :-P

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.


More information about the Digitalmars-d-learn mailing list