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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 9AA0E7F75C for ; Sun, 7 Sep 2014 11:31:46 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of jean-denis.eiden@orange.fr) identity=pra; client-ip=80.12.242.123; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jean-denis.eiden@orange.fr"; x-sender="jean-denis.eiden@orange.fr"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of jean-denis.eiden@orange.fr) identity=mailfrom; client-ip=80.12.242.123; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jean-denis.eiden@orange.fr"; x-sender="jean-denis.eiden@orange.fr"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@smtp.smtpout.orange.fr) identity=helo; client-ip=80.12.242.123; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="jean-denis.eiden@orange.fr"; x-sender="postmaster@smtp.smtpout.orange.fr"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArkBAO8kDFRQDPJ7lGdsb2JhbABZ0k6EOBABAQEBBwsLCRIshBIfCwEFTAonWAkVDBsJiBwBGJgCnH4Bh0mPaoMZgR0FinmGR44SlEGBboM5AQEB X-IPAS-Result: ArkBAO8kDFRQDPJ7lGdsb2JhbABZ0k6EOBABAQEBBwsLCRIshBIfCwEFTAonWAkVDBsJiBwBGJgCnH4Bh0mPaoMZgR0FinmGR44SlEGBboM5AQEB X-IronPort-AV: E=Sophos;i="5.04,481,1406584800"; d="scan'208";a="78031750" Received: from smtp01.smtpout.orange.fr (HELO smtp.smtpout.orange.fr) ([80.12.242.123]) by mail3-smtp-sop.national.inria.fr with ESMTP; 07 Sep 2014 11:31:46 +0200 Received: from PCdejd ([92.130.204.91]) by mwinf5d24 with ME id o9Xl1o00B1yqDis039Xl2U; Sun, 07 Sep 2014 11:31:45 +0200 X-ME-Helo: PCdejd X-ME-Date: Sun, 07 Sep 2014 11:31:45 +0200 X-ME-IP: 92.130.204.91 Message-ID: <91F16B653D20446DA42F7B673FD5509D@PCdejd> From: "Jean-Denis Eiden" To: Date: Sun, 7 Sep 2014 11:31:45 +0200 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Windows Mail 6.0.6002.18197 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6002.18463 Subject: [Caml-list] listes qui bouclent Bonjour à tous, CaML light permet la construction suivante : #let rec liste = 0::1::2::3::liste;; liste : int list = [0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; ...] Cela étant, j'aimerais pouvoir faire la même chose en paramétrant la période ; par exemple, j'aimerais créer [ 0 ; 1 ; 2 ; ... ; n-1 ; 0 ; 1 ; 2 ; ... ] : #let repète n = let aux = ref [] in for i = n-1 downto 0 do aux:= i::(!aux) done; !aux;; repète : int -> int list = #let cyclique n = let aux = repète n in let rec liste = aux @ liste in liste;; Mais là : let cyclique n = let rec liste = (repète n) @ liste in liste;; > ^^^^^^^ Ce genre d'expressions n'est pas autorisé comme membre droit d'un "let rec". Est-ce seulement un problème de syntaxe ou bien y a-t-il impossibilité absolue, la taille de la liste servant de période devant être connue à la compilation ? Cordialement, Jean-Denis Eiden