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 KAA20188 for caml-redistribution; Mon, 11 Jan 1999 10:19:01 +0100 (MET) 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 LAA03921 for ; Sun, 10 Jan 1999 11:53:42 +0100 (MET) Received: from landsraad.net (caladan.arrakis.es [195.5.65.34]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id LAA26049 for ; Sun, 10 Jan 1999 11:53:41 +0100 (MET) Received: from ind-cr.uclm.es (jjgarcia@ij-207.arrakis.es [195.5.79.207]) by landsraad.net (8.9.1a/8.9.1) with ESMTP id LAA23519 for ; Sun, 10 Jan 1999 11:55:34 +0100 (MET) Sender: weis Message-ID: <369885D1.1C8A1269@ind-cr.uclm.es> Date: Sun, 10 Jan 1999 11:49:53 +0100 From: Juan Jose Garcia Ripoll X-Mailer: Mozilla 4.05 [en] (X11; I; Linux 2.0.34 i686) MIME-Version: 1.0 To: Caml list Subject: Map is not tail recursive Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, I've had a look at the List package and it seems that it is not properly tail recursive. Even more, for medium to large lists it exhausts the stack. I would suggest either recoding it as let map f a = let domap f done todo = match todo with [] -> List.reverse done | (x::xs) -> domap (f x)::done xs in domap f [] a Another possibility would be to introduce destructive operations such as Scheme's setcdr! and setcar!. This would eliminate the need of using List.reverse, at the cost of introducing some imperative style. Please excuse any mistake -- I'm quite new to this language. Regards Juanjo