Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] patterns usage
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Eugene Ossintsev <eugos@g...>
Subject: [Caml-list] patterns usage
Hello,

There is a construction like

   match Stream.peek strm with
   | Some (' ' | '\010' | '\013' | '\009') -> ...
   | ...

which is frequently repeated throughout the code.
Is it the "right way" to rewrite it having added

   let is_space = function
     | Some (' ' | '\010' | '\013' | '\009') -> true
     | _ -> false

in order to use like

   match Stream.peek strm with
   | c when is_space c -> ...
   | ...

 ?

-- 
Eugene Ossintsev

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners