From: John Max Skaller <skaller@maxtal.com.au>
To: luther@dpt-info.u-strasbg.fr
Cc: Max Skaller <maxs@in.ot.com.au>,
Damien Doligez <Damien.Doligez@inria.fr>,
caml-list@inria.fr
Subject: Re: variables in 'let rec'
Date: Thu, 30 Mar 2000 19:52:37 +1000 [thread overview]
Message-ID: <38E323E5.1327C333@maxtal.com.au> (raw)
In-Reply-To: <20000329132920.A28331@dpt-info.u-strasbg.fr>
Sven LUTHER wrote:
>
> On Tue, Mar 28, 2000 at 11:03:36AM +1000, Max Skaller wrote:
> > Damien Doligez wrote:
> > >
> > > >From: Max Skaller <maxs@in.ot.com.au>
> > > >
> > > >Alternatively, you can just use
> > > >
> > > > let rec x' () = ...
> > > > and ...
> > > > let x = x()
> > > >
> > > >in lieu of what you really wanted: (that is,
> > > >there is a workaround).
> > >
> > > But that doesn't work for "let rec x = 1 :: x", which is the most
> > > interesting feature of O'Caml's recursive value definitions.
> >
> > It doesn't?
> >
> > let rec x'() = 1 :: x()'
> > let x = x'()
>
> FYI :
>
> bash-2.03$ ocaml
> Objective Caml version 2.99 (99/12/08)
>
> # let rec x = 1 :: x ;;
> val x : int list =
> [1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1;
> 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1;
> 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1;
> 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1;
> 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1;
> 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1;
> 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1;
> 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1;
> 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1;
> 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1;
> 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1;
> 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1; 1;
> ...]
Ah! I withdraw my last comment: the list is constructed as instructed,
resulting in a circular list. The printer routines recognizes this,
or at least is smart enough to apply a printing limit.
_Traversing_ the list may take infinite time, but examining
the first n elements will not. (And the construction is
constant time :-)
--
John (Max) Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net
next prev parent reply other threads:[~2000-04-02 21:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-03-25 14:55 Damien Doligez
2000-03-28 1:03 ` Max Skaller
2000-03-29 11:29 ` Sven LUTHER
2000-03-30 9:52 ` John Max Skaller [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-03-28 10:01 Damien Doligez
2000-03-30 9:19 ` John Max Skaller
2000-03-22 9:41 David Chemouil
2000-03-23 1:37 ` Max Skaller
2000-03-23 15:57 ` Xavier Leroy
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=38E323E5.1327C333@maxtal.com.au \
--to=skaller@maxtal.com.au \
--cc=Damien.Doligez@inria.fr \
--cc=caml-list@inria.fr \
--cc=luther@dpt-info.u-strasbg.fr \
--cc=maxs@in.ot.com.au \
/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