Re: match case unused
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <CAJMfKEUZj0xMgi=NsfrkATrjPMc+yVi+imQO68njh5rYwNNygQ@mail.gmail.com> |
On Fri, Feb 27, 2015 at 5:16 PM, Roelof Wobben [email protected] [ocaml_beginners] <[email protected]> wrote: > > > I have to rewrite a not function with pattern matching. > > So I did this : > > let not x = > match x with > x -> false > | _ -> true ;; > Another possible misconception is with the use of the "when" clause. You could define "not" thus: let not x = match x with | _ when x -> false | _ -> true or equivalently: let not x = match x with | x when x -> false | _ -> true However, your example does not have a "when" clause.