From: Brian H. <bri...@ql...> - 2003-06-20 22:05:44
|
On Fri, 20 Jun 2003, Nicolas Cannasse wrote: > I added the complete documention to Enum. (comments are welcome ) > While reading the documentation specification, I found a bug. > Actually the iter2 , fold2 and others were not correct because of the > following > > f (t.next()) (u.next()) > > if t.next() was called and then u.next() was raising No_more_elements , we > were loosing an element of t. > I modified the implementation of theses so now the element is saved and > pushed back (using the new "push" function) if needed. > But as for map2 (and map2i) this would involve setting up a try .. catch > block for every call to next , which has already been tagged as > not-so-efficient , I have then temporay removed theses two. This is one place where has_next would be usefull. It would allow us to implement iter2 like: let iter2 f t u = let rec loop () = if (t.has_next()) && (u.has_next()) then begin f (t.next()) (u.next()); loop () end else () in loop () Brian |