transversal sum
    bearophile via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Fri Nov  7 03:29:23 PST 2014
    
    
  
Marc Schütz:
>         int[][] input = new int[][2];
>         input[0] = [1, 2, 3, 4];
>         input[1] = [5, 6, 7, 8];
>         writeln(input);
>
>         auto sums = input
>                 .transposed
>                 .map!(a => a.sum);
>         writeln(sums);
>     }
>
> Output:
>
>     [[1, 2, 3, 4], [5, 6, 7, 8]]
>     [6, 8, 10, 12]
Jack specified:
> I have rectangular forward range of forward ranges (not arrays):
You "input" range is not just a Forward Range.
And by the way, your array literal can be written more simply 
like this:
int[][2] input = [[1, 2, 3, 4], [5, 6, 7, 8]];
Bye,
bearophile
    
    
More information about the Digitalmars-d-learn
mailing list