Pouknouki

Untitled

Feb 3rd, 2016
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 1.15 KB | None | 0 0
  1. 1=2;;
  2. `a`=`b`;;
  3. 1=2 or 1<2;;
  4. 1<>2 || not 1=2;;
  5. 1=1 && 2=2;;
  6. 1=1 & 2=2;;
  7. 3+5;;
  8. 3*5;;
  9. 3.*.5.;;
  10. 3/5;;
  11. 1073741824+1;;
  12. exp(1.)+.exp(-1.);;
  13. 3.*.0.5;;
  14. 'a';;
  15. `a`;;
  16. "bonjour" ^ "les enfants";;
  17. hd [1,2,3];;
  18. [|1;`a`; 1a |];;
  19. [|1;2;3|];;
  20. 0::[|1;2;3|];;
  21. [|1;3;4|].(0);;
  22.  
  23.  
  24.  
  25. hd [1;2;3];;
  26. tl [1;2;4;5;2;3];;
  27. [1;2;3].(2);;
  28.  
  29. let x=1 in 2+x;;
  30. let x=1;;
  31. x;;
  32. 2*x where x=3;;
  33. let (x,y)=(1,2) in x+y;;
  34. let x=1 and y=2 in x+y;;
  35. let f1= function x->x*x;;
  36. f1(3);;
  37.  
  38. let f2= fun x->x*x;;
  39. f2(2);;
  40.  
  41. let f3 x=x*x;;
  42. f3 3;;
  43.  
  44. let p1(x,y)=x*y;;
  45. p1(2, 4);;
  46.  
  47. let p2 x y=x*y;;
  48. p2(3, 4);;
  49.  
  50. let p3=function(x,y)->x*y;;
  51. p3(2, 4);;
  52.  
  53. let x=1;;
  54. let f=fun y->x+y;; f(2);;
  55.  
  56. let x=ref(0);;
  57. x:=!x+1;;
  58. x;;
  59.  
  60. (*Exercice 3*)
  61. log(2.71);;
  62.  
  63. exp(2.)*.log(3.)/.(cos(1.)*.cos(1.));;
  64.  
  65. let ch = function x->(exp(x)+.exp(-1.*.x))/.2.;;
  66. ch(1.);;
  67.  
  68.  
  69.  
  70. (*Exerice 4*)
  71. let P1 = (1=1);;
  72. let P2 = (2=2);;
  73.  
  74. let xor = fun x y-> (x || y) && not (y && x);;
  75.  
  76. let xor2 = function(x, y)-> (x || y) && not (y && x);;
  77.  
  78. xor P1 P2;;
  79. xor2 (P1, P2);;
  80. (P1 || P2) && not (P1 && P2);;
  81.  
  82. (*Exercice 5*)
  83. let rec ari a r n = if n = 0 then a else (ari a r (n-1)) + r;;
  84.  
  85. ari 0 2 3;;
Advertisement
Add Comment
Please, Sign In to add comment