True. Then I think this is the best suggestion:
string|array crop(string|array x, int from, int to) { if(from<0) from += sizeof(x); if(to<0) to += sizeof(x); return x[from..to]; }
but preferably implemented in C so that we get the type
function((0=string|array),int,int:0)
and the optimization rule crop(a,b,c) -> a[b..c] if b and c >= 0.
/ Martin Nilsson (har bott i google)
Previous text:
2003-03-06 00:46: Subject: negative indices in array ranges
Why would it have to handle open ranges? 0 is the first element, -1 the last.
/ Martin Stjernholm, Roxen IS