ddash.range.slicing

Returns a slice of a range

Members

Functions

slice
auto slice(Range range, size_t start, int end)
auto slice(Range range, size_t start)

Returns a slice of range from start up to, but not including, end

Examples

1 auto arr = [1, 2, 3, 4, 5];
2 
3 assert(arr.slice(1).equal([2, 3, 4, 5]));
4 assert(arr.slice(0, 0).empty);
5 assert(arr.slice(1, 3).equal([2, 3]));
6 assert(arr.slice(0, -2).equal([1, 2, 3]));
7 
8 assert(arr.initial.equal([1, 2, 3, 4]));
9 
10 assert(arr.tail.equal([2, 3, 4, 5]));

Meta