We have slices, do we have Strides?

Jonathan M Davis jmdavisProg at gmx.com
Mon Aug 8 11:55:46 PDT 2011


> I have a problem I'd really like to use Strides for to simplify my code.
> Currently, I do this:
> foreach(n; 0..chunks)
> comp_arr[n] = values[(n * step_size) + n]
> if(!all_same(comp_arr, comp_arr[0]))
> 
> It would eliminate an entire 2 lines of code for each time I want
> strides, to be able to do this:
> if(!all_same(bytes[i..$..step_size])
> 
> Meaning, start with i, grab all elements at i + block_size * n until
> block_size * n > bytes.length. Right?
> 
> -Kai Meyer

Would std.range.stride work for you?

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list