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 CAA32496; Wed, 10 Dec 2003 02:09:52 +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 CAA00890 for ; Wed, 10 Dec 2003 02:09:50 +0100 (MET) Received: from smtp.siren.ocn.ne.jp (siren.ocn.ne.jp [211.129.13.170]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id hBA19m107903 for ; Wed, 10 Dec 2003 02:09:49 +0100 (MET) Received: from PWARP (p5243-ipad09kyoto.kyoto.ocn.ne.jp [221.190.248.243]) by smtp.siren.ocn.ne.jp (Postfix) with SMTP id D656B225C; Wed, 10 Dec 2003 10:09:45 +0900 (JST) Message-ID: <003d01c3beba$4a3f6910$0274a8c0@PWARP> From: "Nicolas Cannasse" To: "Caml Mailing List" , "Dustin Sallings" References: <2111F26F-2A1D-11D8-8637-000393CB0F1E@spy.net> Subject: Re: [Caml-list] stream conversion Date: Wed, 10 Dec 2003 10:09:40 +0900 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 char:01 prettier:01 enumerations:01 enum:01 enum:01 extlib:01 sourceforge:01 char:01 cannasse:01 nicolas:01 nicolas:01 closure:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > I have a need to convert a ``string stream'' to a ``char stream.'' > It's a little unclear to me how I'd accomplish this. This is the best > I've been able to come up with so far, but I have to imagine there's a > prettier solution: BTW, I don't know if you're using streams in a parser, but if you're using them only as enumerations, you should consider using the Enum module instead ( Enum is part of the ExtLib : http://ocaml-lib.sourceforge.net ) One example of conversion of a string enum to a char enum : open ExtString let to_chars e = Enum.concat (Enum.map String.enum e) I don't know about the Stream implementation, but Enum are purely functional. That means there is no temporary "char list" or "char array" created anywhere, only a int ref in a closure actually. 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