splicerN

Splice x in N parts, all as equal in lengths as possible.

Safely avoids range checking thanks to D's builtin slice expressions. Use in divide-and-conquer algorithms such as quicksort and binary search.

@trusted
splicerN
(
uint N
T
)
(
T[] x
)

Examples

enum count = 6;

immutable int[count] x = [0, 1, 3, 3, 4, 5];
immutable y = x.splicerN!count;

static foreach (i; 0 .. count) {
	assert(y.at!i.equal(x[i .. i + 1]));
}

Meta