rotate left an array
rassoc
rassoc at posteo.de
Tue Oct 4 00:49:45 UTC 2022
On 10/3/22 23:06, Ali Çehreli via Digitalmars-d-learn wrote:
> auto rotatedView(R)(R range)
Or even more generic by chaining two slices in case the range permits it:
auto rotatedView(R)(R range, long n = 1)
if (...)
{
if (n == 0) return range;
...
n %= range.length;
...
return chain(slice1, slice2);
}
Used something like that in previous advent of code challenges where they expect you to go for doubly linked lists due to large buffer size.
More information about the Digitalmars-d-learn
mailing list