caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Kerneis <kerneis@enst.fr>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] large hash tables
Date: Wed, 20 Feb 2008 00:34:14 +0100	[thread overview]
Message-ID: <20080220003414.7dd5e353@tatanka.kerneis.info> (raw)
In-Reply-To: <33d2b3f70802191501v39346a56x4b1852b84d4067b4@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1217 bytes --]

Hello,

it won't solve any of you problems but I have a few remarks on your
code:

> exception SplitError
> 
> let read_whole_chan chan =
>     let movieMajor = Hashtbl.create 777777 in

Here, movieMajor in declared inside read_whole_chan and never returned,
so you won't be able to use it (but it might as well be a test program
I guess).

>     let rec loadLines count =
>         let line = input_line chan in
>         let murList = Pcre.split line in
>         match murList with
>             | m::u::r::[] ->
>                 let rFloat = float_of_string r in
>                 Hashtbl.add movieMajor m (u, rFloat);
>                 loadLines (count + 1)

You use tail-recursion properly so your Stack overflow doesn't come
from there. No idea why it occurs, though...

>             | _ -> raise SplitError
>   in
> 
>     try
>         loadLines 0
>     with
>         End_of_file -> ()
>     ;;
> 
> let read_whole_file filename =
>     let chan = open_in filename in
>     read_whole_chan chan
>     ;;

You should close the chan when you're done.

> let filename = Sys.argv.(1);;
> 
> let str = read_whole_file filename;;


Regards,
-- 
Gabriel Kerneis

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2008-02-19 23:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-19 23:01 John Caml
2008-02-19 23:34 ` Gabriel Kerneis [this message]
2008-02-19 23:36 ` [Caml-list] " Gerd Stolpmann
2008-02-19 23:51 ` Francois Rouaix
2008-02-20  9:37   ` Berke Durak
2008-02-20  9:56     ` Berke Durak
2008-02-20 12:48 ` Richard Jones
2008-02-20 15:54 ` Oliver Bandel
2008-02-21 22:45   ` John Caml
2008-02-22  0:33     ` Richard Jones
2008-02-24  5:39       ` John Caml
2008-02-22 14:19     ` Brian Hurt

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=20080220003414.7dd5e353@tatanka.kerneis.info \
    --to=kerneis@enst.fr \
    --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).