Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] stream conversion
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jean-Baptiste Rouquier <jean-baptiste.rouquier@e...>
Subject: Re: [Caml-list] stream conversion
brogoff@speakeasy.net wrote:

>The documentation in the Stream library for the stream builders (you use
>Stream.of_string) states :
>  
>
Ah yes, I remember reading that one year ago, sorry.
Here is a more readable solution :

#load "camlp4o.cma";;
let stream_of_string s =
  let len = String.length s in
  let rec stream pos =
    if pos < len then [< 's.[pos]; stream (pos+1) >] else [<>] in
  stream 0

let rec convert = parser
  | [< 'string; stream >] -> [<stream_of_string string; convert stream>]
  | [<>] -> [<>]

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