Iterating over multiple collections in parallel

Yigal Chripun yigal100 at gmail.com
Sat Jul 5 14:59:30 PDT 2008


Manfred_Nowak wrote:
> Koroskin Denis wrote:
> 
>> int[] c = new int[a.length];
>> foreach (i : a; j : b; ref k : c) {
>>      k = a + b;
>> }
> 
> What's wrong with
> 
>   auto c= a .* b;
> 
> except, that it is neither suggested nor supported?
> 
> 
> Or
> 
>   auto c= a (*) b;
> 
> which was suggested some long time ago, but has not got through?
> 
> 
> Is it horrible then to define:
> 
> void opDotMul(T)(out T c, T x, T y){
>     assert( x.length ==  y.length);
>     c.length= x.length;
>     foreach( i,v; x){ 
>         c[i]= x[i] * y[i];	  
>     }
> }
> 
> -manfred

what about:

int[100] a, b, c;
for (int i = 0; i < 100; ++i) {
  a[i] = myCrazyFunkyFunction(b[i], c[i]);
}

D does not and should not have an opMyCrazyFunkyFunction.




More information about the Digitalmars-d mailing list