From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA20462; Wed, 4 Feb 2004 18:48:51 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA19984 for ; Wed, 4 Feb 2004 18:48:50 +0100 (MET) Received: from postfix4-1.free.fr (postfix4-1.free.fr [213.228.0.62]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id i14Hmnv13866 for ; Wed, 4 Feb 2004 18:48:49 +0100 (MET) Received: from warp (lns-th2-5f-81-56-197-80.adsl.proxad.net [81.56.197.80]) by postfix4-1.free.fr (Postfix) with SMTP id 8D088B0F06; Wed, 4 Feb 2004 18:48:46 +0100 (CET) Message-ID: <013201c3eb47$0e20ecb0$ef01a8c0@warp> From: "Nicolas Cannasse" To: "Christian Schaller" , References: Subject: Re: [Caml-list] Doing the transition from imperative to functional (and some other Q) Date: Wed, 4 Feb 2004 18:48:07 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Loop: caml-list@inria.fr X-Spam: no; 0.00; cannasse:01 warplayer:01 caml-list:01 buffer:01 believer:99 disappoint:99 buffer:01 extlib:01 enum:01 functionals:01 cannasse:01 arrays:01 nicolas:01 nicolas:01 underlying:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > Now comes the funny part. Actually, right now I'm not sure how to > represent the buffer variable internally. As you can see, in the first > part I chose string, because of the .[] operator. However, I cannot use > string, because this data type doesn't have any fold function. Right > now I do not want to make a decision about the data type used, except > that I know that it must be a sequence of characters. > > Though I am a strong believer in static typing, above versions > disappoint me heavily because of type restrictions. Is there any way to > write above version on arbitrary sequences like Arrays, Lists, Strings? > > Actually, I would have preferred the buffer data type because I can use > that one for fast reading of a file. However, I cannot fold over a > buffer :( > > Any enlightening hints? You should have a look at ExtLib Enum module that enable you to apply fold's and others functionals operations on any underlying data structure (string, array, list, .... ). http://ocaml-lib.sf.net Regards, Nicolas Cannasse ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners