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 IAA23812; Tue, 9 Dec 2003 08:56:15 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA23595 for ; Tue, 9 Dec 2003 08:56:14 +0100 (MET) Received: from bob.west.spy.net (mail.west.spy.net [66.149.231.226]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hB97uCr23975 for ; Tue, 9 Dec 2003 08:56:12 +0100 (MET) Received: from [192.168.1.50] (dustinti.west.spy.net [192.168.1.50]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client did not present a certificate) by bob.west.spy.net (Postfix) with ESMTP id 302BD570B for ; Mon, 8 Dec 2003 23:56:05 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v606) Content-Transfer-Encoding: 7bit Message-Id: <2111F26F-2A1D-11D8-8637-000393CB0F1E@spy.net> Content-Type: text/plain; charset=US-ASCII; format=flowed To: Caml Mailing List From: Dustin Sallings Subject: [Caml-list] stream conversion Date: Mon, 8 Dec 2003 23:56:00 -0800 X-Mailer: Apple Mail (2.606) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; char:01 prettier:01 cae:99 her:97 string:03 string:03 chunk:03 chunk:03 let:04 let:04 fingerprint:04 i'd:06 source:07 source:07 stream:07 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: let stream_convert source = let chunk = ref (Stream.of_string (Stream.next source)) in Stream.from (fun x -> try Stream.empty !chunk; try Stream.empty source; None with Stream.Failure -> chunk := (Stream.of_string (Stream.next source)); Some (Stream.next !chunk) with Stream.Failure -> Some (Stream.next !chunk) ) ;; Any suggestions? -- SPY My girlfriend asked me which one I like better. pub 1024/3CAE01D5 1994/11/03 Dustin Sallings | Key fingerprint = 87 02 57 08 02 D0 DA D6 C8 0F 3E 65 51 98 D8 BE L_______________________ I hope the answer won't upset her. ____________ ------------------- 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