1. Home
  2. /
  3. Ocaml
  4. /
  5. Max of Two Numbers

Max of Two Numbers - Ocaml Typing CST Test

Loading…

Max of Two Numbers — Ocaml Code

Finds the maximum of two numbers.

let max a b = if a > b then a else b
let () = Printf.printf "%d\n" (max 10 20)

Ocaml Language Guide

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.

Primary Use Cases

  • ▸Compiler and interpreter development
  • ▸Formal verification and theorem proving
  • ▸High-performance and reliable software
  • ▸Financial modeling and risk analysis
  • ▸Systems and network programming

Notable Features

  • ▸Strong static type system with type inference
  • ▸Pattern matching for concise code
  • ▸Modules, functors, and polymorphic variants
  • ▸Garbage-collected runtime
  • ▸Interoperability with C and JavaScript via BuckleScript/Js_of_ocaml

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.

More Ocaml Typing Exercises

OCaml Counter and Theme ToggleOCaml Simple AdditionOCaml FactorialOCaml Fibonacci SequenceOCaml List SumOCaml Even Numbers FilterOCaml Conditional Counter IncrementOCaml Resettable CounterOCaml Theme Toggle Only

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher