Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Circuralizing lists
Date: Mon, 26 Nov 2007 22:41:49 +0000	[thread overview]
Message-ID: <200711262241.49833.jon@ffconsultancy.com> (raw)
In-Reply-To: <9d3ec8300711261346r4b74f5gddce229324dcad2c@mail.gmail.com>

On Monday 26 November 2007 21:46, Till Varoquaux wrote:
> Writing the list containing an inifinite number of ones can easily be done
> as:
>
> let rec ones = 1::ones
>
> I however don't know of any type safe to generate the infinite list
> which is the repetition of a given list (in a type safe non lazy way).
> What I'm looking for is a code that would do:
>
> let circularize  = function
>
>     | [] -> failwith "cannot circularize empty lists"
>     | l -> let rec res = l@res in res
>
> Is this at all possible?

OCaml only permits restricted static forms of this construct. The only 
practical application of this restricted form that I am aware of is in 
avoiding dummy values when creating simple cycles such as the environments of 
recursive closures in an interpreter.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/products/?e


  parent reply	other threads:[~2007-11-26 22:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-26 21:46 Till Varoquaux
2007-11-26 21:58 ` [Caml-list] " Alain Frisch
2007-11-26 22:41 ` Jon Harrop [this message]
2007-12-20 21:04 ` David Thomas

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=200711262241.49833.jon@ffconsultancy.com \
    --to=jon@ffconsultancy.com \
    --cc=caml-list@yquem.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