swig/Examples/ocaml/argout_ref/example_prog.ml
Zackery Spytz 1be9f5fec3 [OCaml] Fix some of the OCaml examples
Update some of the OCaml examples so that they run successfully with
`make check-ocaml-examples` (important for the CI). Some of the
examples were written to depend on passed arguments.

Temporarily disable the broken std_string example.
2019-01-03 07:34:25 -07:00

17 lines
518 B
OCaml

(* example_prog.ml *)
open Swig
open Example
exception BadReturn
let x = if Array.length Sys.argv > 1 then int_of_string Sys.argv.(1) else 16
let y = if Array.length Sys.argv > 2 then int_of_string Sys.argv.(2) else 12
let (xf,yf) = match _factor '((x to int),(y to int)) with
C_list [ C_int a ; C_int b ] -> a,b
| _ -> raise BadReturn
let _ = print_endline
("Factorization of " ^ (string_of_int x) ^
" and " ^ (string_of_int y) ^
" is " ^ (string_of_int xf) ^
" and " ^ (string_of_int yf))