From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 9A2A2BC75 for ; Thu, 17 Feb 2005 19:58:45 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j1HIwjER008303 for ; Thu, 17 Feb 2005 19:58:45 +0100 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 TAA31664 for ; Thu, 17 Feb 2005 19:58:44 +0100 (MET) Received: from yukon.yapper.org (adsl-67-120-175-89.dsl.lsan03.pacbell.net [67.120.175.89]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j1HIwhNT008293 for ; Thu, 17 Feb 2005 19:58:44 +0100 Received: from kenai.yapper.org (kenai.yapper.org [67.120.175.90]) by yukon.yapper.org (Postfix) with ESMTP id BC5B36B9; Thu, 17 Feb 2005 11:00:47 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kenai.yapper.org (Postfix) with ESMTP id 41B766EE; Thu, 17 Feb 2005 11:00:47 -0800 (PST) Message-ID: <4214E9DE.8040107@cs.caltech.edu> Date: Thu, 17 Feb 2005 11:00:46 -0800 From: Jason Hickey Organization: Caltech User-Agent: Mozilla Thunderbird 0.9 (X11/20041127) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Alex Baretta Cc: caml-list@inria.fr Subject: Re: [Caml-list] Immediate recursive functions References: <4214B8F1.7010402@barettadeit.com> In-Reply-To: <4214B8F1.7010402@barettadeit.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4214E965.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 4214E963.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 recursive:01 baretta:01 wrote:01 rec:01 pred:01 syntax:01 syntax:01 fixpoint:01 rec:01 val:01 ...:98 functions:01 defined:01 int:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.2 X-Spam-Level: Alex Baretta wrote: > I sometimes feel the need for a mu operator. I'm thinking of something > like the following: > > # (rec f x -> if x <= 0 then 1 else x * (f (pred x))) 5 > - : int = 120 ... > This is not really a feature wish so much a bit of insane curiosity. Is > there any specific reason for not having this in the core language syntax? I can't give any arguments why your specific syntax is not allowed. In principle it isn't necessary, since a general fixpoint can be defined. # let rec fix f x = f (fix f) x;; val fix : (('a -> 'b) -> 'a -> 'b) -> 'a -> 'b = # fix (fun f i -> if i = 0 then 1 else i * f (i - 1)) 10;; - : int = 3628800 # fix (fun f i j -> if i = 0 then 1 else j * f (i - 1) j) 10 5;; - : int = 9765625 The drawback is that (fix f x) is likely to be a bit more expensive to evaluate than the let-rec version. Jason -- Jason Hickey http://www.cs.caltech.edu/~jyh Caltech Computer Science Tel: 626-395-6568 FAX: 626-792-4257