Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
40 lines (36 sloc) 870 Bytes
module M = struct let foo = 3 end;;
foo;;
open M;;
foo;;
#part 1
let average x y =
let open Int64 in
x + y / of_int 2;;
#part 2
let average x y =
Int64.(x + y / of_int 2);;
#part 3
module Interval = struct
type t = | Interval of int * int
| Empty
let create low high =
if high < low then Empty else Interval (low,high)
end;;
#part 4
module Extended_interval = struct
include Interval
let contains t x =
match t with
| Empty -> false
| Interval (low,high) -> x >= low && x <= high
end;;
Extended_interval.contains (Extended_interval.create 3 10) 4;;
#part 5
module Extended_interval = struct
open Interval
let contains t x =
match t with
| Empty -> false
| Interval (low,high) -> x >= low && x <= high
end;;
Extended_interval.contains (Extended_interval.create 3 10) 4;;