[Issue 10754] std.range.rotate?

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Sep 10 15:44:48 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=10754

crazymonkyyy at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |crazymonkyyy at gmail.com

--- Comment #1 from crazymonkyyy at gmail.com ---
I also dislike the wonky bringToFront; tho I think it should be in place 

my take:
```d
void rotate(T)(T foo,int i){
        auto bar=foo.cycle.drop(i).take(foo.length).array[];
        foreach(ref e;foo){
                e=bar.front;
                bar.popFront;
}}
unittest{
        auto foo=[1,2,3,4,5];
        foo.rotate(2);
        foo.writeln;
}
```

--


More information about the Digitalmars-d-bugs mailing list