Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wish for option iterators #3762

Closed
vicuna opened this issue Sep 21, 2002 · 1 comment
Closed

Wish for option iterators #3762

vicuna opened this issue Sep 21, 2002 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Sep 21, 2002

Original bug ID: 1401
Reporter: administrator
Status: closed
Resolution: won't fix
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)

Bug description

Hello!

I have encountered a situtation where the precondition that
two lists be of the same length is too strict. Yet, I must
iterate on the two lists contemporarily. Hence, I would like
to express the wish to extend the standard library List
module with such iterators as the following:

let rec iter2opt (f:'a option -> 'b option -> unit) l1 l2 =
match l1, l2 with
| [], [] -> ()
| h1 :: t1, [] -> f (Some h1) None; string_iter2opt f t1 []
| [], h2 :: t2 -> f None (Some h2); string_iter2opt f [] t2
| h1 :: t1, h2 :: t2 -> f (Some h1) (Some h2);
string_iter2opt f t1 t2

I offer to write them myself, should the Caml team deem such
an addition to the standard library to be useful for everybody.

Alex

@vicuna
Copy link
Author

vicuna commented Apr 18, 2004

Comment author: administrator

My feeling: not useful often enough to be worth inclusion in stdlib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant