From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 9ED747F2AA for ; Tue, 18 Dec 2012 12:22:01 +0100 (CET) Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of julien.blond@gmail.com) identity=pra; client-ip=209.85.212.43; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="julien.blond@gmail.com"; x-sender="julien.blond@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail4-smtp-sop.national.inria.fr: domain of julien.blond@gmail.com designates 209.85.212.43 as permitted sender) identity=mailfrom; client-ip=209.85.212.43; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="julien.blond@gmail.com"; x-sender="julien.blond@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail4-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-vb0-f43.google.com) identity=helo; client-ip=209.85.212.43; receiver=mail4-smtp-sop.national.inria.fr; envelope-from="julien.blond@gmail.com"; x-sender="postmaster@mail-vb0-f43.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArEBANJQ0FDRVdQrk2dsb2JhbABEvh0IFg4BAQEBCQkLCRQEI4IeAQEEAScZARsdAQMBCwYFCzsiAREBBQEcBhOIAAEDCQaaCowzgXGBCoUdChknDVmIdgEFDJEAA5JXgzOOaBYphBU X-IronPort-AV: E=Sophos;i="4.84,308,1355094000"; d="scan'208";a="166173538" Received: from mail-vb0-f43.google.com ([209.85.212.43]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 18 Dec 2012 12:22:00 +0100 Received: by mail-vb0-f43.google.com with SMTP id fs19so652201vbb.2 for ; Tue, 18 Dec 2012 03:21:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=k92haakHsbhQHHoU8uLcCJwk0FU4CaQOn/cinHgUwSw=; b=pj93ue4sr/5bv9zoh58Ba8ohsXkCG9XDGFwKNZXJAu0ok5xt6JCnSiuzy2kEVR6U8J 6/KHDxFuQusv/Y0zMk5cIqbbNKYwE8s0jwA063A198FLSZob8qOkEqCnoSZsepy4334a 34Gm/VCuQY2ySGPyDL3nrD1+RFa0w/rniTW5AJzhJHLkyGvZAFE72Q471OOK4rJwvfp+ IqHSTcCB191p1zdL60xYaPhUUjLBrvPQUWpNryn3qYY8pO4ICnYiNA8VB38Ezsl+B77p RnhYydACNwSpf5/WJLXehu+51aMNSDef88hhEDCuDcfw4jNqQE2RTZXLeOYdgTw6gRun APMw== MIME-Version: 1.0 Received: by 10.52.178.225 with SMTP id db1mr2132275vdc.10.1355829719467; Tue, 18 Dec 2012 03:21:59 -0800 (PST) Received: by 10.220.115.201 with HTTP; Tue, 18 Dec 2012 03:21:59 -0800 (PST) In-Reply-To: <50d02b65.6c4cb40a.66ab.4256SMTPIN_ADDED_BROKEN@mx.google.com> References: <50d02b65.6c4cb40a.66ab.4256SMTPIN_ADDED_BROKEN@mx.google.com> Date: Tue, 18 Dec 2012 12:21:59 +0100 Message-ID: From: Julien Blond To: Eric Jaeger Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=bcaec5196d71ce061104d11eb441 Subject: Re: [Caml-list] Function returning recursive lists --bcaec5196d71ce061104d11eb441 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Hi Eric, I tried to do something like that some times ago, while my concern was about some tricky recursive module definition, i think the problem was the same : the chicken-egg one. Your docycle is trying to define something it must already know and the problem can't be escaped for evaluation order prevents any value to be recursive at definition time. The recursivity can be achieved by using a second construction pass that corresponds to additional properties (lazyness or mutability or hacking through Obj). Those properties will necessarily occur either explicitly (like OCaml) or implicitly (like in Haskell). So, the real question, as far as i understand your problem, is : are you asking how to hide those properties in OCaml or to see if you need to ask your purchasing department some quantum computer that can predict the address of a future allocated block ? ;) -- Julien 2012/12/18 Eric Jaeger > Hi everyone,**** > > ** ** > > There are various discussions on recursive lists in the archive, yet I was > wondering whether or not it was possible in pure OCaml to write a function > returning non-constant recursive lists.**** > > ** ** > > For example, I would like to have a function =93docycle:=92a list->=92a l= ist=94 > that takes a non recursive list and transforms it into a recursive list > containing the same elements. That is, =93docycle [1;2;3]=94 would return= a > list structurally equivalent to =93let rec c=3D1::2::3::c in c=94. So far= , my > various attempts (OCaml 3.12) have not been successful. Another good > example is to have a List.map compatible with recursive lists.**** > > ** ** > > Please note that it is, in a way, a theoretical (and possibly na=EFve) > question :**** > > **- **I do not consider recursive lists as the perfect > implementation for my problem**** > > **- **I do not care about efficiency**** > > **- **I do not want to use an ad hoc mutable/lazy list datatype > (unless I=92ve also a conversion function toward standard lists)**** > > **- **I do not want to use Obj or other similar tricks**** > > It=92s just that I=92m curious whether or not what I=92m trying to achiev= e is > possible.**** > > ** ** > > Regards, Eric**** > > ** ** > --bcaec5196d71ce061104d11eb441 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable
Hi Eric,

I tried to do something li= ke that some times ago, while my concern was about some tricky recursive mo= dule definition, i think the problem was the same : the chicken-egg one. Yo= ur docycle is trying to define something it must already know and the probl= em can't be escaped for evaluation order prevents any value to be recur= sive at definition time. The recursivity can be achieved by using a second = construction pass that corresponds to additional properties (lazyness or mu= tability or hacking through Obj). Those properties will necessarily occur e= ither explicitly (like OCaml) or implicitly (like in Haskell).

So, the real question, as far as i understand your problem, is : are yo= u asking how to hide those properties in OCaml or to see if you need to ask= your purchasing department some quantum computer that can predict the addr= ess of a future allocated block ? ;)
=A0
-- Julien


2012/12/18 Eric Jaeger <eric.jaeger@ssi.gouv.fr>

Hi everyone,

=A0

There are various discussions on recursive lists i= n the archive, yet I was wondering whether or not it was possible in pure O= Caml to write a function returning non-constant recursive lists.<= /u>

=A0

For example, I would like to have = a function =93docycle:=92a list->=92a list=94 that takes a non recursive= list and transforms it into a recursive list containing the same elements.= That is, =93docycle [1;2;3]=94 would return a list structurally equivalent= to =93let rec c=3D1::2::3::c in c=94. So far, my various attempts (OCaml 3= .12) have not been successful. Another good example is to have a List.map c= ompatible with recursive lists.

=A0

Please note that it is, in a way, = a theoretical (and possibly na=EFve) question :

= -=A0=A0=A0=A0=A0=A0=A0=A0=A0 I do not consider recursive lists as the perfect implement= ation for my problem

-=A0=A0=A0=A0=A0=A0=A0=A0=A0 <= span lang=3D"EN-US">I do not care about efficiency

=

-=A0=A0=A0=A0=A0=A0=A0=A0=A0 <= span lang=3D"EN-US">I do not want to use an ad hoc mutable/lazy list dataty= pe (unless I=92ve also a conversion function toward standard lists)<= u>

-=A0=A0=A0=A0=A0=A0=A0=A0=A0 <= span lang=3D"EN-US">I do not want to use Obj or other similar tricks=

It=92s just that I=92m curious whether or not what I= =92m trying to achieve is possible.

=A0

=A0 Regards, Eric

=A0


--bcaec5196d71ce061104d11eb441--