Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2003-12-10 (01:09)
From: Nicolas Cannasse <warplayer@f...>
Subject: Re: [Caml-list] stream conversion
> 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 : )

One example of conversion of a string enum to a char enum :

open ExtString
let to_chars e =
    Enum.concat ( 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 Archives:
Bug reports: FAQ:
Beginner's list: