From: Pierre Weis <Pierre.Weis@inria.fr>
To: Damien.Doligez@inria.fr (Damien Doligez)
Cc: caml-list@inria.fr
Subject: Re: Ask for explanation -- possibly repeated
Date: Sun, 12 Dec 1999 23:33:47 +0100 (MET) [thread overview]
Message-ID: <199912122233.XAA12778@pauillac.inria.fr> (raw)
In-Reply-To: <199912111827.TAA06475@tobago.inria.fr> from "Damien Doligez" at Dec 11, 99 07:27:50 pm
> >From: Benoit de Boursetty <debourse@email.enst.fr>
> >
> ># let translate_tree =
> > let rec aux father (Classical_node (data, sons)) =
> > let rec this_node = Node (father, data,
> > List.map
> > (aux (Some this_node))
> > sons)
> > in this_node
> > in aux None
>
> >So, is there an applicative workaround? I know how to do it with mutable
> >values / references, but...
As usual: hide the side effect into the lazy side of the language that
is usually considered as pure and applicative, add a bit of
eta-expansion if your language does not know lazy evaluation properly,
and you get a simple workaround:
let translate_tree t =
let rec aux father (Classical_node (data, sons)) =
let rec this_node = lazy (Node (father, data,
List.map
(aux (Some (Lazy.force this_node)))
sons))
in Lazy.force this_node
in aux None t;;
val translate_tree : 'a classical_tree -> 'a tree = <fun>
Pierre Weis
INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/
next prev parent reply other threads:[~1999-12-12 22:34 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-12-11 18:27 Damien Doligez
1999-12-12 22:33 ` Pierre Weis [this message]
1999-12-13 0:25 ` Benoit de Boursetty
1999-12-13 16:21 ` Pierre Weis
-- strict thread matches above, loose matches on Subject: below --
1999-12-08 5:07 Benoit de Boursetty
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=199912122233.XAA12778@pauillac.inria.fr \
--to=pierre.weis@inria.fr \
--cc=Damien.Doligez@inria.fr \
--cc=caml-list@inria.fr \
/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;
as well as URLs for NNTP newsgroup(s).