coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Saulo Araujo <saulo2 AT gmail.com>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Returning a tuple from a function
- Date: Sat, 6 Aug 2016 18:40:00 -0300
- Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=saulo2 AT gmail.com; spf=Pass smtp.mailfrom=saulo2 AT gmail.com; spf=None smtp.helo=postmaster AT mail-io0-f177.google.com
- Ironport-phdr: 9a23:OSqBQR2v0nSI6ZossmDT+DRfVm0co7zxezQtwd8ZsegUIvad9pjvdHbS+e9qxAeQG96Ks7QU1aGP7vGocFdDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXsq3G/pQQfBg/4fVIsYL+kQsiC0Y/uirH60qaQSj0AvCC6b7J2IUf+hiTqne5Sv7FfLL0swADCuHpCdrce72ppIVWOg0S0vZ/or9YwuxhX7vkm7otLVbjwV6U+V71RSjo8YE4v48i+jhDeSQzHz2EVT2cR2k5TChXB60vSUZL4sy+8ve14jnrJdfbqRKw5DGzxp5xgTwXl3X8K
Actually, the let construction can do the job. For example:
Definition f (x: nat) := (x, x, x).
Eval compute in
let '(x, y, z) := f 1 in
(x, y, z).
Pay attention to the single quote character after the let keyword. This let sintax is explained in the session "Second destructuring let syntax" of the Coq reference manual (https://coq.inria.fr/refman/Reference-Manual004.html)
Regards,
Saulo
On Sat, Aug 6, 2016 at 6:08 PM, Gaetan Gilbert <gaetan.gilbert AT ens-lyon.fr> wrote:
You can use match, or if you want to use let it seems you have to do it in 2 stages:
let (p, c) := f x in let (a, b) := p in ...
In fact this is what Coq prints if you do
Check (fun x => match f x with ( (a,b), c) => 0 end).
Gaëtan Gilbert
On 06/08/2016 23:00, Aymeric Fromherz wrote:
Hi,
I have a function f with signature nat -> nat * Z * Z
I would like to retrieve the result values when calling it by doing
let (a, b, c) := f n,
but I get the following error :
Error: Destructing let on this type expects 2 variables.
Is there a way to do something similar?
Thanks,
Aymeric Fromherz
- [Coq-Club] Returning a tuple from a function, Aymeric Fromherz, 08/06/2016
- Re: [Coq-Club] Returning a tuple from a function, Gaetan Gilbert, 08/06/2016
- Re: [Coq-Club] Returning a tuple from a function, Saulo Araujo, 08/06/2016
- Re: [Coq-Club] Returning a tuple from a function, Gaetan Gilbert, 08/06/2016
Archive powered by MHonArc 2.6.18.