From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA29256 for caml-redistribution; Tue, 14 Dec 1999 18:29:55 +0100 (MET) 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 QAA20497 for ; Tue, 14 Dec 1999 16:32:42 +0100 (MET) Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id QAA23969 for ; Tue, 14 Dec 1999 16:32:40 +0100 (MET) Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.9.3/beig-1.0) with ESMTP id QAA48474 ; Tue, 14 Dec 1999 16:32:40 +0100 (CET) Received: from localhost (frisch@localhost) by clipper.ens.fr (8.9.2/jb-1.1) id QAA03743 ; Tue, 14 Dec 1999 16:32:40 +0100 (MET) Date: Tue, 14 Dec 1999 16:32:40 +0100 (MET) From: Alain Frisch X-Sender: frisch@clipper To: Norman Ramsey cc: caml-list@inria.fr Subject: Re: OCaml and tail recursion In-Reply-To: <199912131727.MAA20344@labrador.eecs.harvard.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: weis On Mon, 13 Dec 1999, Norman Ramsey wrote: > [snip] > Apparently ocamlc doesn't optimize tail calls. Yes it does. It is difficult to help if you don't give the code or its structure. If you build a list with the characters you parse, consider rewriting a code like : let rec map f = function | h::t -> (f h)::(m f t) | _ -> [] (which is not tail recursive) into something like: let rec map f l = let rec aux accu = function | h::t -> aux ((f h)::accu) t | _ -> [] in List.rev (aux [] l) (List.rev is tail recursive) Alain