OCaml is an industrial strength programming language supporting functional, imperative and object-oriented styles

News RSSRSS

More...

A taste of OCaml

(* Binary tree with leaves car­rying an integer. *)
type tree = Leaf of int | Node of tree * tree

let rec exists_leaf test tree =
  match tree with
  | Leaf v -> test v
  | Node (left, right) ->
      exists_leaf test left
      || exists_leaf test right

let has_even_leaf tree =
  exists_leaf (fun n -> n mod 2 = 0) tree

OCaml is a lot more powerful than this simple example shows. See more examples!

Packages

Package Version Date
ppx_deriving_yojson3.1Nov 24, 2017
rawlink0.6Nov 24, 2017
mirage-types-lwt3.0.7Nov 24, 2017
mirage-types3.0.7Nov 24, 2017
mirage-runtime3.0.7Nov 24, 2017
mirage3.0.7Nov 24, 2017