Skip to content

Instantly share code, notes, and snippets.

@bitbckt
Created April 13, 2010 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitbckt/364991 to your computer and use it in GitHub Desktop.
Save bitbckt/364991 to your computer and use it in GitHub Desktop.
Parallel invoke HOF in OCaml
let invoke (f : 'a -> 'b) x : unit -> 'b =
let input, output = Unix.pipe() in
match Unix.fork() with
| -1 -> (let v = f x in fun () -> v)
| 0 -> Unix.close input;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment