On 10/25/05, Brian Brunswick <brian.brunswick@gmail.com> wrote:
On 25/10/05, Amit Dubey <amit.dubey@gmail.com> wrote:
> I see the problem.  I think there may be another problem if first < -(length
> s).  Is it best to fix these bugs, or change the documentation?

My opinion would be fix the problem, since we already have String.sub
to throw exceptions.

OK, but this raises two questions:
(1) what would be the behaviour when (length s) <= i  < 2 * (length s).  Similar to when 0 > i > -1 * (length s) (i.e. substact length s)?
(2) what about when i < -2 * (length s) or i >= 2 * (length s)?
(Where i = first/last)

Eg on the project I used String.slice in, I wanted a version of
List.combine, but with the spec of Haskell zip, ie just discarding
extra length. It might be reasonable to add that family too.

What about meeting halfway and adding a function like truncate pair:

let truncate_pair xl yl =
  let rec aux accu_x accu_y xl yl = match xl,yl with
  | x::xs, y::ys -> aux (x::accu_x) (y::accu_y) xs ys
  | _, _ -> (rev accu_x, rev accu_y)
    aux [] [] xl yl