learning F#, it seems pretty cool, favourite functional language so far.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

12345678
  1. module Hamming
  2. let hamming s1 s2 =
  3. let pairs = Seq.zip s1 s2
  4. Seq.fold (fun a x -> if (x |> fst) <> (x |> snd) then (a + 1) else a) 0 pairs
  5. let distance (strand1: string) (strand2: string): int option =
  6. if String.length strand1 <> String.length strand2 then None else Some(hamming strand1 strand2)