View Source Akin.Hamming (Akin v0.2.0)
Functions to calculate the Hamming Distance between 2 given strings. The Hamming Distance is the the smallest number of substitutions needed to change one string into the other string.
If the strings are not the same length, nil is returned If the string are equal, 0.0 is returned.
Summary
Functions
Callback implementation for Akin.Task.compare/2
.
Calculates the Hamming distance between 2 given strings.
Functions
@spec compare( %Akin.Corpus{ list: term(), original: term(), set: term(), stems: term(), string: term() }, %Akin.Corpus{ list: term(), original: term(), set: term(), stems: term(), string: term() } ) :: float()
Callback implementation for Akin.Task.compare/2
.
@spec compare( %Akin.Corpus{ list: term(), original: term(), set: term(), stems: term(), string: term() }, %Akin.Corpus{ list: term(), original: term(), set: term(), stems: term(), string: term() }, Keyword.t() ) :: float()
Calculates the Hamming distance between 2 given strings.
Examples
iex> Akin.Hamming.compare(%Akin.Corpus{string: "toned"}, %Akin.Corpus{string: "roses"}, []) 0.6 iex> Akin.Hamming.compare(%Akin.Corpus{string: "toned"}, %Akin.Corpus{string: "peanut"}, []) nil iex> Akin.Hamming.compare(%Akin.Corpus{string: "toned"}, %Akin.Corpus{string: "toned"}, []) 0.0