My fold approach version: let folded (out, value) o v = let a = if out then Some o else None in let b = if value then Some v else None in List.fold_left ( fun accum elem -> match elem with None -> accum | Some x -> x :: accum ) [] [ b; a ]
or when following the way the other functions are notated (o and v not as parameters but in the environment) so that you can paste it into your code: let folded_env (out, value) = let a = if out then Some o else None in let b = if value then Some v else None in List.fold_left ( fun accum elem -> match elem with None -> accum | Some x -> x :: accum ) [] [ b; a ] If let ... = ... in let ... = ... in ... is slower than than let ... = ... and let ... = ... in ... then use the latter one ;-) Ciao, Oliver -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs