Browse thread
[Caml-list] stream conversion
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| 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 : 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