Mode:
Duration:
1
2
let rec sum_list lst = match lst with [] -> 0 | x::xs -> x + sum_list xs
let () = Printf.printf "%d\n" (sum_list [1;2;3;4;5])Coding works best on desktop or with an external keyboard.
let rec sum_list lst = match lst with [] -> 0 | x::xs -> x + sum_list xs
let () = Printf.printf "%d\n" (sum_list [1;2;3;4;5])Coding works best on desktop or with an external keyboard.
Sums elements of a list recursively.
let rec sum_list lst = match lst with [] -> 0 | x::xs -> x + sum_list xs
let () = Printf.printf "%d\n" (sum_list [1;2;3;4;5])OCaml is a functional, imperative, and object-oriented programming language in the ML family. It features strong static typing, type inference, and a powerful module system, making it suitable for compiler construction, systems programming, and formal verification.
Origin & Creator
Developed in 1996 by Xavier Leroy and the INRIA team in France as an extension of the Caml language.
Industrial Note
OCaml is widely used in formal methods, theorem provers (e.g., Coq), and financial software requiring high reliability.