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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 514E77F2AA for ; Tue, 18 Dec 2012 09:37:51 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of eric.jaeger@ssi.gouv.fr) identity=pra; client-ip=86.65.182.16; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="eric.jaeger@ssi.gouv.fr"; x-sender="eric.jaeger@ssi.gouv.fr"; x-conformance=sidf_compatible Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of eric.jaeger@ssi.gouv.fr) identity=mailfrom; client-ip=86.65.182.16; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="eric.jaeger@ssi.gouv.fr"; x-sender="eric.jaeger@ssi.gouv.fr"; x-conformance=sidf_compatible Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@smtp.ssi.gouv.fr) identity=helo; client-ip=86.65.182.16; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="eric.jaeger@ssi.gouv.fr"; x-sender="postmaster@smtp.ssi.gouv.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EAGAq0FBWQbYQ/2dsb2JhbABEgkm7XhZzgiUIAh0BBTEoBWg/AQQeBYgHmFKREZBFjWuDKQOILIVRjWWKcIJ0 X-IronPort-AV: E=Sophos;i="4.84,308,1355094000"; d="scan'208,217";a="186613053" Received: from smtp.ssi.gouv.fr ([86.65.182.16]) by mail1-smtp-roc.national.inria.fr with ESMTP; 18 Dec 2012 09:37:50 +0100 Received: from smtp-switch.internet.local (smtp-switch [192.168.3.9]) by smtp.ssi.gouv.fr (Postfix) with ESMTP id 3F1FF90B97F for ; Tue, 18 Dec 2012 09:37:50 +0100 (CET) From: "Eric Jaeger" To: Date: Tue, 18 Dec 2012 09:37:49 +0100 Message-ID: <003801cddcfa$f66325c0$e3297140$@jaeger@ssi.gouv.fr> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0039_01CDDD03.58278DC0" X-Mailer: Microsoft Outlook Thread-Index: Ac3c+vX/tIi4mSRoSeaiY8eS00MPkw== Content-Language: fr Subject: [Caml-list] Function returning recursive lists This is a multi-part message in MIME format. ------=_NextPart_000_0039_01CDDD03.58278DC0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi everyone, =20 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. =20 For example, I would like to have a function =93docycle:=92a list->=92a lis= t=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 va= rious attempts (OCaml 3.12) have not been successful. Another good example is to have a List.map compatible with recursive lists. =20 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 achieve = is possible. =20 Regards, Eric =20 ------=_NextPart_000_0039_01CDDD03.58278DC0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Hi everyone,

=  

There a= re various discussions on recursive lists in the archive, yet I was wonderi= ng whether or not it was possible in pure OCaml to write a function returni= ng non-constant recursive lists.

=  

For example, I would like to have a function “docycle:= 217;a list->’a list” that takes a non recursive list and tra= nsforms it into a recursive list containing the same elements. That is, = 220;docycle [1;2;3]” would return a list structurally equivalent to &= #8220;let rec c=3D1::2::3::c in c”. So far, my various attempts (OCam= l 3.12) have not been successful. Another good example is to have a List.ma= p compatible with recursive lists.

 

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

-          = I do not consider recursi= ve lists as the perfect implementation for my problem

=

-    &= nbsp;     I do not care about efficiency

-       = ;   I do not wa= nt to use an ad hoc mutable/lazy list datatype (unless I’ve also a co= nversion function toward standard lists)

-      &n= bsp;   I do not= want to use Obj or other similar tricks

It’s just that I’m curious whether o= r not what I’m trying to achieve is possible.

 

  Regards, Eric

<= p class=3DMsoNormal> 

= ------=_NextPart_000_0039_01CDDD03.58278DC0--