Akin.Hamming (Akin v0.1.7) View Source
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.
Link to this section Summary
Functions
Callback implementation for Akin.Task.compare/2
.
Calculates the Hamming distance between 2 given strings.
Link to this section Functions
Specs
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
.
Specs
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