Version franēaise
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Unexpected restriction in "let rec" expressions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-02-27 (17:20)
From: Dirk Thierbach <dthierbach@g...>
Subject: Re: [Caml-list] Unexpected restriction in "let rec" expressions
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]]

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

- Dirk