I was just thinking of having an array (or multiset, anything with keys) to copy instead of ranges for the datatypes where that is more useful. But copying a selected range from a mapping or multiset isn't that far-fetched, I think I've had use for it sometime...
Ie, mixed range_min,range_max; mapping in,out=([]); foreach (in;mixed key;mixed data) if (range_min<=key && range_max>=key) out[key]=data; return out;
or, in this case, level--; ... out[key]=level?copy_value(data,level):data;
or so. (Add suitable magic to handle recursive datatypes.)
/ Mirar
Previous text:
2003-03-06 13:03: Subject: negative indices in array ranges
Ok, then we simply have different opinions on that one.
I otoh think it's a bit ugly to graft filtering functionality into copy_value; it seems arbitrary that such a generic function should handle ranges which isn't even applicable for many of the types it supports. It could just as well take an array of specific indices to copy, or a parameter to match prefixes on strings to copy, or something like that.
Adding a level parameter to copy_value sounds like a really good suggestion, though.
/ Martin Stjernholm, Roxen IS