summaryrefslogtreecommitdiff
path: root/sem_6/HLIN603/ocaml/TP2/ex1.caml
blob: ab3237a593bcd3131abce374ad6de7cdf81cda49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class min ( xi : int ) =
object ( self )
  val mutable x = xi
  method get = x
  method set n = x <- n
  method min y = if self#get < y then self#get else y
end;;
class min_zero xi =
object
  inherit min xi
  method get = 0
end;;
let o1 = new min 4;;
let o2 = new min_zero 0;;
o1#min 2;;
o1#min 7;;
o2#min 2;;
o2#min (-2);;