Files
comp3958/lecture05/sum_integers.ml
T
2026-02-05 11:37:06 -08:00

13 lines
244 B
OCaml

let () =
let rec aux sum =
try
aux @@ Scanf.scanf " %d" (fun x -> sum + x)
with
| Scanf.Scan_failure _ ->
Scanf.scanf " %s" (fun _ -> ());
aux sum
| End_of_file -> sum
in
Printf.printf "%d\n" @@ aux 0;;