Advertisement
techno-

Untitled

Jan 9th, 2023 (edited)
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.88 KB | None | 0 0
  1. Dadas estas clases y objetos:
  2.  
  3. class superclasesencilla(i0: int) =
  4. object
  5.          val mutable i = i0
  6.          method get = i
  7.          method set i' = i<-i'
  8. end;;
  9.  
  10. class subclasesencilla(i0: int)=
  11. object
  12.         inherit superclasesencilla i0
  13.         method swap i' = let v = i
  14.                              in (i<-i';v)
  15. end;;
  16.  
  17. let objetillo=
  18. object(this)
  19.   val mutable l = [0]
  20.   method get = List.hd l
  21.   method set i' = l <- [i']
  22.   method swap i' = let v = this#get
  23.                    in(this#set i';v)
  24. end;;
  25.  
  26. let f1 (o: <set: int->unit>) = 1+o#get
  27. let f4 (o:<set: int->unit; get: int>) = 1 + o#get;;
  28. let f6 = (o: <set: int->unit; get: int; ..>) = 1 + o#get;;
  29. let f8= (o:#superclasesencilla)=1+o#get;;
  30. let f10 (o: #superclasesencilla) = 1 + (o#swap 0);;
  31. let f12 (o: #subclasesencilla)= 1 + o#get;;
  32.  
  33.  
  34. ¿Es verdad o falso que las funciones f1 y f4 aceptan las mismas entradas?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement