Re: match case unused

"Lukasz Stafiniak [email protected] [ocaml_beginners]" <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.