From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id ED45FBBCA for ; Mon, 25 Feb 2008 21:55:19 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.25,403,1199660400"; d="scan'208";a="9567492" Received: from 109.215.100-84.rev.gaoland.net (HELO [192.168.0.3]) ([84.100.215.109]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 25 Feb 2008 21:55:19 +0100 Message-ID: <47C32A42.3050606@free.fr> Date: Mon, 25 Feb 2008 21:51:14 +0100 From: "Tiphaine.Turpin" User-Agent: Thunderbird 1.5.0.10 (X11/20070303) MIME-Version: 1.0 To: Dirk Thierbach Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] OO programming References: <47BD44FE.3050001@irisa.fr> <20080224163308.GA3459@feanor> <47C288FD.8070602@free.fr> <47C2E369.9080206@gmail.com> <47C2E68E.2020401@exalead.com> <20080225201201.GB5414@feanor> In-Reply-To: <20080225201201.GB5414@feanor> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Spam: no; 0.00; 0100,:01 berke:01 durak:01 beginner's:01 ocaml:01 bug:01 char:01 char:01 beginners:01 imho:01 wrote:01 caml-list:01 caml-list:01 int:01 int:01 Dirk Thierbach a écrit : > On Mon, Feb 25, 2008 at 05:02:22PM +0100, Berke Durak wrote: > >> Yes that could be nice but it's no biggie IMHO. >> >> let init n f = >> let s = make n (f 0) in >> for i=1 to n-1 do >> set s i (f i); >> done; >> s >> >> let init : int -> (int -> char) -> string = init >> > > Nice. I hadn't seen this trick before. You don't happen to know a > similar trick that works with methods? > I get the idea. Would the following satisfy your needs (you may place the code and the type in any order) ? let _ = object (self) method init n f = let s = make n (f 0) in for i=1 to n-1 do set s i (f i); done; s method virtual init : int -> (int -> char) -> string end Tiphaine Turpin > - Dirk > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >