added OCaml and Python implementations