From: Bardur A. <oca...@sc...> - 2004-04-01 12:24:40
|
Hi there, I have a suggestion for an additional function to put in the Option module: let map_default f default = function | None -> default | Some v -> f v As you can see it's sort of "Option.may for expressions". I chose the name map_default because the function is basically a combination of Option.map and Option.default. Its behaviour is exactly identical to Option.default default (Option.map f x) where x is the last parameter to map_default. It can be convenient to have this function when building predicates for e.g. Set.for_all when the set in question contains option-type values. I also find that having one function for the job instead of having to string Option.map and Option.default together reduces clutter. Cheers, -- Bardur Arantsson <ba...@im...> <ba...@sc...> - Mmmmmmmmmmmmmmmm... something. Homer Simpson | The Simpsons |