does anyone how a concept for insideout iterating
I have this:
```d
struct cursor(T){
T[] data; alias data this;
int index;
ref opIndex(int i){
return data[min($-1,max(0,i+index))];
}
auto forward(){
struct range{
T[] data;
int index;
ref T front()=>data[0];
void popFront(){
data=data[1..$];
index++;
}
bool empty()=>data.length==0;
}
return range(data[index..$],0);
}
auto back(){
struct range{
T[] data;
int index;
ref T front()=>data[$-1];
void popFront(){
data=data[0..$-1];
index--;
}
bool empty()=>data.length==0;
}
return range(data[0..index],-1);
}
auto forwardthenback()=>chain(forward,back);
}
```
and Im using [index-sign(index)] to access the reliant other
member surely theres a better way
---
```d
foreach(ref me,ref other;[1,2,3,4,5].???(2)){
writeln(me,','other);
}
```
```
3,3
4,3
5,4
2,3
1,2
```
(reminder tuples and refness dont actaully work, and im modifying
the center out)