From: Amit D. <ami...@gm...> - 2005-10-25 12:07:31
|
On 10/25/05, Brian Brunswick <bri...@gm...> wrote: > > On 25/10/05, Amit Dubey <ami...@gm...> 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) <=3D 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 >=3D 2 * (length s)? (Where i =3D 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 =3D let rec aux accu_x accu_y xl yl =3D match xl,yl with | x::xs, y::ys -> aux (x::accu_x) (y::accu_y) xs ys | _, _ -> (rev accu_x, rev accu_y) in aux [] [] xl yl -Amit |