On Fri, 26 Jan 2007, Mac Mason wrote:
> I've got a file that has many, many whitespace-delimited integers (and
> one whitespace-delimited string, as the very first element).
>
> I'm looking for a clean way to read them in one at a time; what I'd
> really like is a stream (or an Enum, I suppose) that's constructed
> from these values. I can put this together as a combination of
> Std.input_all, Str.split, and so on, but it's really awful and I don't
> know much about the tail-recursive properties of those functions (like
> I said: many, many integers). It seems like I should be able to
> (ab)use the stream syntax or module to do this for me.
>
> Thoughts?
If you data is bigger than Sys.max_string_length (or 16MB if you want to
be portable), then you might want to use ocamllex.
Otherwise, for simplicity I would use micmatch, but since I wrote it, I am
definitely biased.
There are other solutions. Genlex might be one, if your format is
compatible.
Martin
--
Martin Jambon
http://martin.jambon.free.fr
.