Improving std.range.Zip
    Tomek Sowiński 
    just at ask.me
       
    Sun Oct 24 10:54:00 PDT 2010
    
    
  
I have noticed an emerging idiom in my code lately: bring together n  
ranges, transform them to one range using a n-ary function. Currently it's  
achieved with:
map!((a) {return myNaryFun(a._0, a._1, ...); })(zip(range1, range2, ...));
It's a bit of a nuisanse -- rarely do my transforming functions take  
tuples, and there's the necessity of composing 2 higher-order ranges to  
render fairly common functionality. I think Zip could be further  
parametrized with a zipper function, so that the above code would boil  
down to:
zip!myNaryFun(range1, range2, ...);
Having looked at Zip's source, such change shouldn't be a big deal. Oh,  
and the default zipper function would be std.typecons.tuple, not to  
trouble those not keen on generalization.
Good?
-- 
Tomek
    
    
More information about the Digitalmars-d
mailing list