All Some
Implement the function
val all_some : 'a option list -> 'a list option
which converts a list of options into an optional list according to the following specification.
- If
Noneis an element of the listl, thenall_some lisNone. - Otherwise,
all_some lisSome l'wherel'is the list of arguments of theSomeelements ofl.
Examples
let _ = assert (all_some [Some 1; Some 2; Some 3] = Some [1;2;3]) let _ = assert (all_some [Some 1; None; Some 3] = None)