caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Nicolas Cannasse" <warplayer@free.fr>
To: "Caml Mailing List" <caml-list@inria.fr>,
	"Dustin Sallings" <dustin@spy.net>
Subject: Re: [Caml-list] stream conversion
Date: Wed, 10 Dec 2003 10:09:40 +0900	[thread overview]
Message-ID: <003d01c3beba$4a3f6910$0274a8c0@PWARP> (raw)
In-Reply-To: <2111F26F-2A1D-11D8-8637-000393CB0F1E@spy.net>

> 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


      parent reply	other threads:[~2003-12-10  1:09 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-12-09  7:56 Dustin Sallings
2003-12-09 12:08 ` Remi Vanicat
2003-12-09 16:58   ` Jean-Baptiste Rouquier
2003-12-09 17:25     ` brogoff
2003-12-09 17:40       ` Jean-Baptiste Rouquier
2003-12-09 18:30       ` Tim Freeman
2003-12-16 22:42         ` Damien Doligez
2003-12-09 19:13     ` Dustin Sallings
2003-12-09 19:15   ` Dustin Sallings
2003-12-10  1:09 ` Nicolas Cannasse [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='003d01c3beba$4a3f6910$0274a8c0@PWARP' \
    --to=warplayer@free.fr \
    --cc=caml-list@inria.fr \
    --cc=dustin@spy.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).