PageRenderTime 46ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/ocaml/simple/example_prog.ml

#
OCaml | 33 lines | 10 code | 17 blank | 6 comment | 0 complexity | c6b10e5eb7b17e3f184113c829a025bf MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. (* example_prog.ml *)
  2. open Swig
  3. open Example
  4. (* Call our gcd() function *)
  5. exception NoReturn
  6. let x = 42 to int
  7. let y = 105 to int
  8. let g = _gcd '(x,y) as int
  9. let _ = Printf.printf "The gcd of %d and %d is %d\n" (x as int) (y as int) g
  10. (* Manipulate the Foo global variable *)
  11. (* Output its current value *)
  12. let _ = Printf.printf "Foo = %f\n" (_Foo '() as float)
  13. (* Change its value *)
  14. let _ = _Foo '(3.1415926)
  15. (* See if the change took effect *)
  16. let _ = Printf.printf "Foo = %f\n" (_Foo '() as float)