PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 4ms 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
 1(* example_prog.ml *)
 2
 3open Swig
 4open Example
 5
 6(* Call our gcd() function *)
 7
 8exception NoReturn
 9
10let x = 42 to int
11let y = 105 to int
12let g = _gcd '(x,y) as int
13let _ = Printf.printf "The gcd of %d and %d is %d\n" (x as int) (y as int) g
14
15(* Manipulate the Foo global variable *)
16
17(* Output its current value *)
18let _ = Printf.printf "Foo = %f\n" (_Foo '() as float)
19
20(* Change its value *)
21let _ = _Foo '(3.1415926)
22
23(* See if the change took effect *)
24let _ = Printf.printf "Foo = %f\n" (_Foo '() as float)
25
26
27
28
29
30
31
32
33