This is what I have so far. Isn\'t this all that you need? I keep getting the error \"Error: Unbound module Std\"
let r file =
let chan = open_in file in
Another style to read lines from a file using Scanf "string indiciation" and zero-width character. It is like traditional imperative style.
open Scanf
open Printf
(* little helper functions *)
let id x = x
let const x = fun _ -> x
let read_line file = fscanf file "%s@\n" id
let is_eof file = try fscanf file "%0c" (const false) with End_of_file -> true
let _ =
let file = open_in "/path/to/file" in
while not (is_eof file) do
let s = read_line file in
(* do something with s *)
printf "%s\n" s
done;
close_in file
NOTE: