open Base type nucleotide = A | C | G | T let toint = function | A -> 0 | C -> 1 | G -> 2 | T -> 3 let hamming_distance a b = match (a, b) with | [], [] -> Ok 0 | [], _ -> Error "left strand must not be empty" | _, [] -> Error "right strand must not be empty" | l1, l2 -> match List.zip l1 l2 with | Ok res -> Ok (List.filter ~f:(fun (x, y) -> (toint x) <> (toint y)) res |> List.length) | Unequal_lengths -> Error "left and right strands must be of equal length"