From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_FAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 23D16BBCA for ; Wed, 27 Feb 2008 18:20:22 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAABcqxUfVpUAUmWdsb2JhbACQZwEBAQEBBgQGCQgWnTo X-IronPort-AV: E=Sophos;i="4.25,414,1199660400"; d="scan'208";a="8668410" Received: from mail.gmx.net ([213.165.64.20]) by mail1-smtp-roc.national.inria.fr with SMTP; 27 Feb 2008 18:20:21 +0100 Received: (qmail invoked by alias); 27 Feb 2008 17:20:20 -0000 Received: from dialin-145-254-250-108.pools.arcor-ip.net (EHLO dialin-145-254-250-108.pools.arcor-ip.net) [145.254.250.108] by mail.gmx.net (mp036) with SMTP; 27 Feb 2008 18:20:20 +0100 X-Authenticated: #11134691 X-Provags-ID: V01U2FsdGVkX1+vOm9pwwSvmnSQkEblr/00ySXN+VI2t/0zmae9Rt B/KD8DgnlzXBcS Received: from dirk by feanor.private-host.de with local (masqmail 0.2.20) id 1JUPL6-12j-00 for ; Wed, 27 Feb 2008 17:41:04 +0100 Date: Wed, 27 Feb 2008 17:41:04 +0100 To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Unexpected restriction in "let rec" expressions Message-ID: <20080227164104.GA3176@feanor> References: <6f9f8f4a0802260424o5bce2fd9i89fbfa38bb239a6a@mail.gmail.com> <47C524F3.9030005@fmf.uni-lj.si> <6f9f8f4a0802270143o68c58cbfh2ea059cda5c0a744@mail.gmail.com> <20080227120248.GA8000@feanor> <6f9f8f4a0802270604q5c144f26i27214fd738500a74@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6f9f8f4a0802270604q5c144f26i27214fd738500a74@mail.gmail.com> User-Agent: Mutt/1.5.6+20040523i From: Dirk Thierbach X-Y-GMX-Trusted: 0 X-Spam: no; 0.00; 0100,:01 factorial:01 wrote:01 rec:01 caml-list:01 int:01 lazy:02 expression:02 defined:02 btw:03 unexpected:03 let:03 expressions:04 types:05 problem:05 On Wed, Feb 27, 2008 at 03:04:03PM +0100, Loup Vaillant wrote: > Yes, it does, but I have difficulties reducing this expression. Where is the problem? > Do you have another example which can be reduced to head normal form > (say the result is an int instead of a list)? Not with ground types, but would the factorial function help? f (x,g) = (g x, g') where g' 0 = 1 g' y = y * g (y-1) *Main> [loop f x | x <- [0..10]] [1,1,2,6,24,120,720,5040,40320,362880,3628800] One can imagine that in a similar way to the list: The function g goes round the loop and more and more results get defined. BTW, lazy evaluation uses weak head normal form (WHNF), not head normal form. - Dirk