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 SAA29695; Thu, 12 Jun 2003 18:37:58 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA29389 for ; Thu, 12 Jun 2003 18:37:57 +0200 (MET DST) Received: from mail2.tpgi.com.au (mail.tpgi.com.au [203.12.160.58]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h5CGbtH11809 for ; Thu, 12 Jun 2003 18:37:55 +0200 (MET DST) Received: from ozemail.com.au (203-219-67-67-syd-ts23-2600.tpgi.com.au [203.219.67.67]) (authenticated bits=0) by mail2.tpgi.com.au (8.12.9/8.12.9) with ESMTP id h5CGborq004010 for ; Fri, 13 Jun 2003 02:37:52 +1000 Message-ID: <3EE8AC5E.6080409@ozemail.com.au> Date: Fri, 13 Jun 2003 02:37:50 +1000 From: John Max Skaller User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2.1) Gecko/20010901 X-Accept-Language: en-us MIME-Version: 1.0 To: caml-list@inria.fr Subject: Re: [Caml-list] How to find out if a function is tail recursive? References: <200306121443.QAA0000013156@beaune.inria.fr> <3EE8A73A.3020207@ozemail.com.au> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Kaspersky-Antivirus: Passed X-Spam: no; 0.00; ozemail:01 caml-list:01 recursion:01 toxteth:01 glebe:01 2037,:01 9660:01 0850:01 rec:01 nsw:01 snail:02 match:02 wrote:03 recursive:03 btw:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk John Max Skaller wrote: > let rec count lst = > match lst with > | [] -> 0 > | h :: t -> 1 + count t > > which isn't tail recursive. BTW: to see the last line spoils the tail recursion, rewrite it in functional notation: | h ::t -> add(1, count(t)) and you can now see that 'add' is the tail call, not count. -- John Max Skaller, mailto:skaller@ozemail.com.au snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia. voice:61-2-9660-0850 ------------------- 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