ocaml - Using arrays with Ctypes -


i have quicksort function in c want bind ocaml using ctypes.

the declaration follows:

void quicksort(int array[], int first, int last) 

i don't know type put array in second parameter of foreign:

let cquicksort = foreign     "quicksort" (??? @-> int @-> int @-> returning void) ;; 

you can use void pointer in this tutorial.

let cquicksort = foreign     "quicksort" (ptr void @-> int @-> int @-> returning void)  let start = to_voidp (carray.start (carray.of_list int[1;2;3;4;3]));;  let () =      let carr = carray.of_list int [1;2;4;5;3] in         let start = to_voidp (carray.start carr) in             cquicksort start 0 4; 

after quicksort can use carray.to_list sorted list.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -