From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id QAA25081; Thu, 12 Jun 2003 16:31:20 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA25280 for ; Thu, 12 Jun 2003 16:31:19 +0200 (MET DST) Received: from bettysue.stecksoft.com ([66.92.70.205]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h5CEVIT11416 for ; Thu, 12 Jun 2003 16:31:18 +0200 (MET DST) Received: from blimpy (blimpy.stecksoft.com [192.168.100.2]) by bettysue.stecksoft.com (8.12.5/8.12.5) with ESMTP id h5CEVECO031456; Thu, 12 Jun 2003 10:31:14 -0400 Reply-To: From: "Paul Steckler" To: "'Richard Jones'" , Subject: RE: [Caml-list] How to find out if a function is tail recursive? Date: Thu, 12 Jun 2003 10:31:14 -0400 Organization: Stecksoft Message-ID: <000201c330ef$473ea270$0264a8c0@blimpy> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 In-Reply-To: <20030612141549.GA14762@redhat.com> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Spam: no; 0.00; caml-list:01 printf:01 rec:01 recursive:03 tail:03 argument:03 cons:03 let:04 function:09 isn't:11 operator:12 1000000:13 instead:15 length:16 why:17 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > let rec range a b = > if a > b then [] > else a :: range (a+1) b > ;; > > let list = range 1 1000000;; > > Printf.printf "length = %d\n" (List.length list);; > > Can you tell me why this function isn't tail recursive, and > share any useful tips on how to tell whether a function is or > is not tail recursive? The recursive call to range is not the result for its caller. Instead, the result of recursive call is an argument to the cons (the :: operator). -- Paul ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners