Sha256: e666f7326d6ae66449aeef6425c1fff9432fbfbd7520f8c7e83e54e535546687

Contents?: true

Size: 372 Bytes

Versions: 261

Compression:

Stored size: 372 Bytes

Contents

exception NonEqualLengthStringsFound;
fun hamming (s1, s2) = let
    val chars1 = explode s1
    val chars2 = explode s2
    fun hamming' ([],[]) acc = acc
      | hamming' ((x::xs),(y::ys)) acc = hamming' (xs, ys) (acc + (if x = y then 0 else 1))
in
    if (length chars1) <> (length chars2) then raise NonEqualLengthStringsFound
    else hamming' (chars1, chars2) 0
end

Version data entries

261 entries across 261 versions & 1 rubygems

Version Path
trackler-2.2.1.43 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.42 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.41 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.40 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.39 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.38 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.37 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.36 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.35 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.34 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.33 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.32 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.31 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.30 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.29 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.28 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.27 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.26 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.25 tracks/sml/exercises/hamming/example.sml
trackler-2.2.1.24 tracks/sml/exercises/hamming/example.sml