Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: christian konrad <konrad@in.tum.de>
To: caml-list@yquem.inria.fr
Subject: beginners list
Date: Sat, 24 Feb 2007 13:43:31 -0500	[thread overview]
Message-ID: <45E08753.40600@in.tum.de> (raw)

Hello again,

I just signed up to the beginners with the message: "/Your membership to 
the ocaml_beginners mailing list is waiting for the moderator's approval."
/so for a last time I misuse this list, sorry. I wrote this piece of code:

type ergebnis = {teamid1: int; teamid2: int; goals1: int; goals2: int};;
type spieltag = {number: int; ergebnisse: ergebnis list};;

...

let rec readSpieltagelist filehandle numberofgames =
    let createErgebnis tid1 tid2 g1 g2 =
        {teamid1=tid1; teamid2=tid2; goals1=g1; goals2=g2;}
    in
    let rec readErgebnisse fh number =
        match number with
        | 0 -> []
        | n -> let line = (input_line fh) in (Scanf.sscanf line 
"%d\t%d\t%d\t%d" createErgebnis):: (readErgebnisse fh (number-1));
    in
    try
        let spieltag = int_of_string(read_line filehandle) in
        let ergebnislist = (readErgebnisse filehandle numberofgames) in
        {number=spieltag; ergebnisse=ergebnislist;} :: 
(readSpieltagelist filehandle numberofgames);   
    with End_of_file -> [];;

with the hope to read from a file informations like:
1
1   2   3   4
3   2   1   6
4   2   1   9
2
1   4   9   2
3   2   1   9
9   1   2   3
3
...

I would call: readSpieltagelist filehandle 3
in that case.
This code doesn't compile, I get an error with the variable filehandle 
in this expression:

        let ergebnislist = (readErgebnisse filehandle numberofgames) in

"This expression has type unit but is here used with type in_channel"


Why that?? I really do not understand that. Do I use "filehandle" 
somewhere as a unit type? Where, why?


Thanks for help,
chris
//


             reply	other threads:[~2007-02-24 18:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-24 18:43 christian konrad [this message]
2007-02-24 18:59 ` [Caml-list] " Richard Jones
2007-02-24 19:19 ` micha
2007-02-25  1:03 ` Jon Harrop

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=45E08753.40600@in.tum.de \
    --to=konrad@in.tum.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