aAPT
dDebian
fFFmpeg
jJava
mMercurial: Usage
oOCaml
pPostgreSQL

Home Code OCaml

OCaml: Generic

Math

Rounding floats:

let round x = int_of_float (floor (x +. 0.5))

Reading the file

Reading the text file line by line (tail recursive)

let read_lines ic =
    let rec read acc =
        match input_line ic with
        | l -> read (l :: acc)
        | exception End_of_file -> List.rev acc
    in
    read []