-
Notifications
You must be signed in to change notification settings - Fork 64
Description
I've been migrating some list-processing code to use Core_kernel instead of the standard library and noticed that the documentation strings for the two libraries have somehow become interchanged. The standard library documentation for List.exists2 says:
Same as
List.exists, but for a two-argument predicate. RaiseInvalid_argumentif the two lists have different lengths.
In fact, List.exists2 does not always raise Invalid_argument if the two lists have different lengths:
# List.exists2 (>) [1; 2] [3; 1; 0];;
- : bool = trueOn the other hand, the documentation for Core.Std.List.exists2_exn says:
Same as
List.exists, but for a two-argument predicate. RaiseInvalid_argumentif the end of one list is reached before the end of the other.
In fact, Core.Std.List.exists2_exn can fail even if the predicate is satisfied (which should mean that the ends of the lists are not reached):
# Core_kernel.Std.List.exists2_exn ~f:(>) [1; 2] [3; 1; 0];;
Exception: Invalid_argument "length mismatch in exists2_exn: 2 <> 3 ".I'd submit a pull request fixing the documentation (as for the standard library), but wonder if the implementation might be changed instead. It seems a bit inefficient to traverse both lists before starting when the function is supposed to be short-circuiting.