RosettaCodeData/Task/Flow-control-structures/OCaml/flow-control-structures.ocaml
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

10 lines
294 B
Text

exception Found of int
let () =
(* search the first number in a list greater than 50 *)
try
let nums = [36; 23; 44; 51; 28; 63; 17] in
List.iter (fun v -> if v > 50 then raise(Found v)) nums;
print_endline "nothing found"
with Found res ->
Printf.printf "found %d\n" res