Combine Coroutines and Input Ranges for Dead-Simple D Iteration

Adam D. Ruppe destructionator at gmail.com
Tue May 1 07:04:10 PDT 2012


You might find this interesting too...

string yield(string what) { return `if(auto result = 
dg(`~what~`)) return result;`; }

     int opApply(int delegate(ref uint) dg) {
         for (int i = 0; i < array.length; i++)
                 mixin(yield("array[i]"));

         return 0;
     }


The little mixin does the boilerplate making opApply
a bit more succinct, without anything really fancy.


More information about the Digitalmars-d-announce mailing list