jv_free(end_jv);
return 0;
} else {
- int start = (int)jv_number_value(start_jv);
- int end = (int)jv_number_value(end_jv);
- if (start < 0) start = len + start;
- if (end < 0) end = len + end;
+ double dstart = jv_number_value(start_jv);
+ double dend = jv_number_value(end_jv);
+ if (dstart < 0) dstart += len;
+ if (dend < 0) dend += len;
+ if (dstart < 0) dstart = 0;
+ if (dstart > len) dstart = len;
+
+ int start = (int)dstart;
+ int end = (dend > len) ? len : (int)dend;
+ // Ends are exclusive but e.g. 1 < 1.5 so :1.5 should be :2 not :1
+ if(end < dend) end += 1;
- if (start < 0) start = 0;
- if (start > len) start = len;
if (end > len) end = len;
if (end < start) end = start;
assert(0 <= start && start <= end && end <= len);
[][.]
1000000000000000000
null
+
+map([1,2][0:.])
+[-1, 1, 2, 3, 1000000000000000000]
+[[1], [1], [1,2], [1,2], [1,2]]