Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.56 KB | None | 0 0
  1.     ///
  2.     T[2] opIndex(size_t idx) pure
  3.     {
  4.         assert(idx < length);
  5.  
  6.         Coords coords = coordsInSquare(idx);
  7.  
  8.         import std.traits;
  9.         static assert(isMutable!(typeof(coords))); // ok
  10.  
  11.         if(coords.x <= coords.y) // under diagonal line?
  12.         {
  13.             auto latestIdx = srcLength - 1;
  14.  
  15.             // Mirroring coords
  16.             coords.x = latestIdx - coords.x; // Error: cannot modify const expression coords.x
  17.             coords.y = latestIdx - coords.y - 1;
  18.         }
  19.  
  20.         return [coords.x, coords.y];
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement