Shouldn't "crop" on a range return everything _but_ the range? After all, to crop means to _cut away_.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)
Previous text:
2003-03-06 00:54: Subject: negative indices in array ranges
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)