Skip to content

Instantly share code, notes, and snippets.

@zakki
Created August 20, 2012 13:28
Show Gist options
  • Select an option

  • Save zakki/3404032 to your computer and use it in GitHub Desktop.

Select an option

Save zakki/3404032 to your computer and use it in GitHub Desktop.
let window = Dom_html.window;;
let foo i =
let result = try Some (List.find (fun s -> s = i) [0; 1; 5]) with Not_found -> None in
match result with
Some(n) -> window##alert(Js.string (Printf.sprintf "foo Some(%d)" n))
| None -> window##alert(Js.string "foo None");;
for i = 0 to 3 do
foo i
done;;
for i = 0 to 3 do
let result = try Some (List.find (fun s -> s = i) [0; 1; 5]) with Not_found -> None in
match result with
Some(n) -> window##alert(Js.string (Printf.sprintf "Some(%d)" n))
| None -> window##alert(Js.string "None")
done;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment