iterating through a range, operating on last few elements at a time
    Laeeth Isharc via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Thu Aug 13 19:42:26 PDT 2015
    
    
  
I have a range that is an array of structs.  I would like to 
iterate through the range, calling a function with the prior k 
items in the range up to that point and storing the result of the 
function in a new range/array.
what's the best way to do this?  for low fixed k I could use zip 
with staggered slices (s[3..$],s[2..$-1],s[1..$-2],s[0..$-3]) and 
then map.  I can't think of how to do it elegantly.
any thoughts?
    
    
More information about the Digitalmars-d-learn
mailing list