Version française
Home     About     Download     Resources     Contact us    
Browse thread
RE: [Caml-list] Setting the EOL character....
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Matt Boyd <mattwb78756@y...>
Subject: Re: [Caml-list] Setting the EOL character....
Bruno.Verlyck@inria.fr wrote:
>    From: "Richard Lyman" <rich@lithinos.com>
>    Date: Thu, 12 Sep 2002 20:36:45 -0600
> 
>    ... so then - there's no OCaml concept of a global EOL variable, or
>    method that deals with reading in from a stream until the EOL??
> 

I make no promises of efficiency or thread safety, but this should do 
what you want:

let read_until n =
   let buf = Buffer.create 100 in
   fun st ->
     let rec aux = function
       | n' when n' = n ->
           let str = Buffer.contents buf in
           Buffer.reset buf;
           str
       | n' ->
           Buffer.add_char buf n';
           aux (Stream.next st);
     in
     aux (Stream.next st)

let read_until_null = read_until '\000'



> 
> Bruno.
> -------------------
> 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
> 
> 
-------------------
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