caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Oliver Bandel <oliver@first.in-berlin.de>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] read file
Date: Wed, 26 Jan 2005 16:50:13 +0100	[thread overview]
Message-ID: <20050126155013.GA320@first.in-berlin.de> (raw)
In-Reply-To: <Pine.LNX.4.58.0501261436020.12039@quantum06.doc.ic.ac.uk>

On Wed, Jan 26, 2005 at 02:41:41PM +0000, Yan Jun Daisy Chen wrote:
>  I am trying to extract all the
> comments i.e. all the text between (* and *) in a text file and store
> them in a list of string. How do u determin the length of the file?

The length of the file?
Not necessary to know.
Or are the comments maybe as long as the file itself?

You better do using OCaml's built-in operations for reading files.

Look for open_in, read_line and so forth.

You also can use the Buffer-module to be much faster,
when appending strings together to a bigger string.

You can do such scanning with ocamllex. But it's also possible
to write your own scanner.

Do not use Unix-module for that stuff. It's portable to use the built-in
functions open_in and such stuff (like read_line and so forts), or the
Buffer-module.

Use Unix-module only, if you need it (e.g. reading from pipes or such stuff).


Ciao,
   Oliver


  reply	other threads:[~2005-01-26 15:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-25 22:19 open_file yjc01
2005-01-25 22:43 ` [Caml-list] open_file Karl Zilles
2005-01-25 22:58   ` Oliver Bandel
2005-01-26 14:41   ` [Caml-list] read file Yan Jun Daisy Chen
2005-01-26 15:50     ` Oliver Bandel [this message]
2005-01-25 22:54 ` [Caml-list] open_file Karl Zilles
2005-01-26 10:16   ` Marcin 'Qrczak' Kowalczyk
2005-01-25 22:54 ` Oliver Bandel

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=20050126155013.GA320@first.in-berlin.de \
    --to=oliver@first.in-berlin.de \
    --cc=caml-list@yquem.inria.fr \
    /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).