Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: "Loup Vaillant" <loup.vaillant@gmail.com>
To: "Dirk Thierbach" <dthierbach@gmx.de>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Unexpected restriction in "let rec" expressions
Date: Thu, 28 Feb 2008 00:32:29 +0100	[thread overview]
Message-ID: <6f9f8f4a0802271532w76e23340n67ebb6828dc3f904@mail.gmail.com> (raw)
In-Reply-To: <20080227164104.GA3176@feanor>

2008/2/27, Dirk Thierbach <dthierbach@gmx.de>:
> 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?

After reducing the call to loop and inlining f in the resulting
expression, I couldn't reduce the recursive let anymore. I thought of
replacing the let by a lambda expression, but since it is recursive,
it can't be done (or at least it's not trivial). But this is not a
problem anymore.

>  > 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]

Cool, this is exactly what I wanted, thanks.

>  BTW, lazy evaluation uses weak head normal form (WHNF), not head normal
>  form.

This is precisely why I wanted the result type to be such that
WHNF=>HNF. Int is such a type. List is not.

Loup


  reply	other threads:[~2008-02-27 23:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-26 12:24 Loup Vaillant
2008-02-26 14:04 ` [Caml-list] " Jean-Christophe Filliâtre
2008-02-26 14:18 ` Damien Doligez
2008-02-26 14:34   ` Loup Vaillant
2008-02-26 14:51     ` Gabriel Kerneis
2008-02-26 14:56     ` blue storm
2008-02-26 17:48     ` Nicolas Pouillard
2008-02-26 14:57 ` Dirk Thierbach
2008-02-27  8:53 ` Andrej Bauer
2008-02-27  9:43   ` Loup Vaillant
2008-02-27 12:02     ` Dirk Thierbach
2008-02-27 14:04       ` Loup Vaillant
2008-02-27 16:41         ` Dirk Thierbach
2008-02-27 23:32           ` Loup Vaillant [this message]
2008-02-27 19:03 ` Pal-Kristian Engstad
2008-02-27 23:46   ` Loup Vaillant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6f9f8f4a0802271532w76e23340n67ebb6828dc3f904@mail.gmail.com \
    --to=loup.vaillant@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=dthierbach@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox