coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Vilhelm Sjöberg <vilhelm AT cis.upenn.edu>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] heterogeneous tuple element function
- Date: Thu, 15 Jan 2015 18:13:41 -0500
On 2015-01-15 17:41, Jonathan Leivent
wrote:
I would like to write a recursive function that takes 3 arguments: an element index (0-based), a count of elements, and a heterogeneous tuple containing (usually) that many elements - and have it return the indexed element of the tuple if it exists. If the tuple doesn't contain the right number of elements, I don't care what the function does, and I don't want to provide a proof that the tuple contains the right number of elements. The index < count - and if not, then I don't care what the function does. I guess your problem is that you can't write down the type "some tuple with n components (of arbitrary types)". However, you can do something similar, where instead of just the number of tuple components, you give a list of the types in it. The below code differs a little from your definition of right-associated tuple, because I made all the tuples end with a unit value for simplicitly. There are some very similar functions in CPDT (http://adam.chlipala.net/cpdt/html/DataStruct.html), but I can't find this exact one. Require Import List.Vilhelm |
- [Coq-Club] heterogeneous tuple element function, Jonathan Leivent, 01/15/2015
- Re: [Coq-Club] heterogeneous tuple element function, Vilhelm Sjöberg, 01/16/2015
- Re: [Coq-Club] heterogeneous tuple element function, Jonathan Leivent, 01/16/2015
- Re: [Coq-Club] heterogeneous tuple element function, Vilhelm Sjöberg, 01/16/2015
- Re: [Coq-Club] heterogeneous tuple element function, flicky frans, 01/16/2015
- Re: [Coq-Club] heterogeneous tuple element function, Vilhelm Sjöberg, 01/16/2015
- Re: [Coq-Club] heterogeneous tuple element function, Jonathan Leivent, 01/16/2015
- Re: [Coq-Club] heterogeneous tuple element function, Jason Gross, 01/17/2015
- Re: [Coq-Club] heterogeneous tuple element function, Jonathan Leivent, 01/17/2015
- Re: [Coq-Club] heterogeneous tuple element function, Jason Gross, 01/18/2015
- Re: [Coq-Club] heterogeneous tuple element function, Jonathan Leivent, 01/18/2015
- Re: [Coq-Club] heterogeneous tuple element function, Jonathan Leivent, 01/17/2015
- Re: [Coq-Club] heterogeneous tuple element function, Jason Gross, 01/17/2015
- Re: [Coq-Club] heterogeneous tuple element function, flicky frans, 01/16/2015
- Re: [Coq-Club] heterogeneous tuple element function, Vilhelm Sjöberg, 01/16/2015
- Re: [Coq-Club] heterogeneous tuple element function, Jonathan Leivent, 01/16/2015
- Re: [Coq-Club] heterogeneous tuple element function, Vilhelm Sjöberg, 01/16/2015
Archive powered by MHonArc 2.6.18.