Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] A question on matching.

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] A question on matching.


chronological Thread 
  • From: "gallais @ ensl.org" <guillaume.allais AT ens-lyon.org>
  • To: Bernard Hurley <bernard AT marcade.biz>
  • Cc: coq-club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] A question on matching.
  • Date: Sun, 22 Apr 2012 19:11:32 +0100

Hi Bernard,

Using [nat_compare] does the job. It maps two natural
numbers to an element of [comparison] which is either
Lt, Eq or Gt (with the obvious semantics).

Cheers,

=============
Require Import Arith.
Variable n : nat.
Variable A : Type.
Variable a b c : A.

Fixpoint test (m: nat):=
 match nat_compare m n with
   | Lt => a (*return something*)
   | Eq => b (* return something *)
   | Gt => c (* return something *)
 end.
=============
--
gallais


On 22 April 2012 19:00, Bernard Hurley 
<bernard AT marcade.biz>
 wrote:
> Hi,
>
> How would I match [m] so that I could write a Fixpoint with the format?
>
> +++++++++++++++++++++++++++++++++++
> Variable n: nat.
>
> Fixpoint test (m: nat):=
>  match m with
>    | (* m less than n *) => (*return something*)
>    | (* m equals n *) => (* return something *)
>    | _ => (* return something *)
>  end.
> +++++++++++++++++++++++++++++++++++
>
> Cheers,
>
> Bernard.
>
>




Archive powered by MhonArc 2.6.16.

Top of Page