From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 9CAD8BC37 for ; Wed, 10 Feb 2010 04:11:00 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvcDABuycUtI/gDKjGdsb2JhbACDCY9/h3IBAQEKCwoHEiStR5AygS+CSlsE X-IronPort-AV: E=Sophos;i="4.49,440,1262559600"; d="scan'208";a="44381100" Received: from s-utl02-sjpop.stsn.net ([72.254.0.202]) by mail3-smtp-sop.national.inria.fr with SMTP; 10 Feb 2010 04:10:59 +0100 Received: from s-utl02-sjpop.stsn.net ([127.0.0.1]) by s-utl02-sjpop.stsn.net (SMSSMTP 4.1.2.20) with SMTP id M2010020919105724079 for ; Tue, 09 Feb 2010 19:10:57 -0800 X-Spam-Level: Received: from [10.5.95.201] ([10.5.95.201]) by s-utl02-sjpop.stsn.net for caml-list@yquem.inria.fr; Tue, 9 Feb 2010 19:10:55 -0800 Message-ID: <4B7223AA.5020000@frisch.fr> Date: Wed, 10 Feb 2010 04:10:34 +0100 From: Alain Frisch User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.8) Gecko/20100206 Shredder/3.0.2pre MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] The need to specify 'rec' in a recursive function defintion References: <1e7471d51002091250of7a686fq537a03c9401c868f@mail.gmail.com> <1265752863.5482.42.camel@flake.lan.gerd-stolpmann.de> <4B71DA88.8040902@citycable.ch> <1265754854.5482.44.camel@flake.lan.gerd-stolpmann.de> <4B71F8C3.5080306@citycable.ch> In-Reply-To: <4B71F8C3.5080306@citycable.ch> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; frisch:01 frisch:01 recursive:01 defintion:01 guillaume:01 recursion:01 'let:01 rec':01 ocaml:01 polymorphic:01 wrote:01 rec:01 caml-list:01 int:01 int:01 On 2/10/2010 1:07 AM, Guillaume Yziquel wrote: > Is it possible to have polymorphic recursion with vanilla 'let rec' > invocations? This is something that Jacques recently merged in the current development branch. The code below should work with OCaml 3.12. let length v = let rec f : 'a. int -> 'a vec -> int = fun n l -> match l with Nil -> n | Zero ps -> f (2 * n) ps | One (_, ps) -> f (1 + 2 * n) ps in f 0 v -- Alain