coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: "Yevgeniy Makarov" <emakarov AT gmail.com>
- To: coq-club AT pauillac.inria.fr
- Subject: Re: [Coq-Club] Defining merge sort
- Date: Wed, 7 Nov 2007 23:00:40 +0100
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=GILrSFkPt5XYpFtZbFiJIOkaWoj8fJXJ40V71bCdXAO8OmLXjvpB/Q2IhTF60KdJipb1Sf4eOaUWPme9SNYluApBqqKbnB9Xw3HLLJXUh/Spitcp5sPJ9oD+kawCP93EYEY+lJf63sFO9vvOXOZWOsT6QBAGK0iRzIVYjxung0Q=
- List-archive: <http://pauillac.inria.fr/pipermail/coq-club/>
Hello,
I followed Benjamin's hint, and here's my version of merge on lists of
natural numbers:
Require Import List.
Require Import Compare_dec.
Fixpoint merge (l1 : list nat) : list nat -> list nat :=
fix merge_helper (l2 : list nat) :=
match l1, l2 with
| nil, nil => nil
| nil, l => l
| l, nil => l
| x1 :: l1, x2 :: l2 =>
if leb x1 x2
then x1 :: merge l1 (x2 :: l2)
else x2 :: merge_helper l2
end.
However, structural recursion won't work for the mergesort itself,
where one has to recur on halfs of the list, and there Function would
be handy.
Concerning Pierre Castéran's page for mergesort, it looks a little
strange since the traditional presentation of the algorithm does not
mention trees...
Evgeny
- [Coq-Club] Defining merge sort, Edsko de Vries
- Re: [Coq-Club] Defining merge sort, Benjamin Werner
- Re: [Coq-Club] Defining merge sort,
Julien Forest
- Re: [Coq-Club] Defining merge sort, Yevgeniy Makarov
- Re: [Coq-Club] Defining merge sort, Pierre Casteran
- Re: [Coq-Club] Defining merge sort, Edsko de Vries
- Re: [Coq-Club] Defining merge sort,
Edsko de Vries
- Re: [Coq-Club] Defining merge sort, Pierre Courtieu
- Re: [Coq-Club] Defining merge sort, Yevgeniy Makarov
- Re: [Coq-Club] Defining merge sort, frederic . blanqui
- Re: [Coq-Club] Defining merge sort, Matthieu Sozeau
- Re: [Coq-Club] Defining merge sort, Matthieu Sozeau
Archive powered by MhonArc 2.6.16.