[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | christian konrad <konrad@i...> |
| Subject: | beginners list |
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
//