On 11/16/10 03:51, Gabriel Kerneis wrote:
> On Tue, Nov 16, 2010 at 12:43:30PM +0100, Thomas Gazagnaire wrote:
>> You are not forced to use match expression, you can just define :
>> let is_none x = match x with None -> true | Some _ -> false
>> and is_some x = not (is_none x)
>> and then use these functions in your code ...
> 
> Or even simpler:
>   let is_none = (=) None
>   let is_some = (!=) None
> Note that you can use this directly, for instance:
>   List.filter ((!=) None) l

I would like to add that I also follow this general approach consisting
in defining such trivial functions where I need them.  Being trivial
does not mean that they are going to be used everywhere.

It makes the code easier to *read*.

My 2 cents.


Martin

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to