OCaml code snippets proposed as CC-BY-SA 4.0 candidates

Binary Search Tree using inline record, the functional style
(Arguably not something revolutionary but this is my own original code)

   type +'a t =
      | Empty
      | Fork of {left:'a t;item:'a;right:'a t}
   let rec add x t =
      match t with
      | Empty -> Fork {left=Empty;item=x;right=Empty}
      | Fork n ->
         if x < n.item then Fork {n with left=add x n.left}
         else if x > n.item then Fork {n with right=add x n.right}
         else t

Binary Search Tree using inline record, the destructive style

   type 'a t =
      | Empty
      | Fork of {mutable left:'a t;item:'a;mutable right:'a t}
   let rec add x t =
      match t with
      | Empty -> Fork {left=Empty;item=x;right=Empty}
      | Fork n ->
         if x < n.item then (n.left <- add x n.left; t)
         else if x > n.item then (n.right <- add x n.right; t)
         else t