source: http://staffwww.dcs.shef.ac.uk/people/S.Chapman/stringmetrics.html currently implemented:
- hamming distance.
# http://staffwww.dcs.shef.ac.uk/people/S.Chapman/stringmetrics.html#hamming | |
def hamming_distance(str1, str2) | |
str1.split(//).zip(str2.split(//)).inject(0) { |h, e| e[0]==e[1] ? h+0 : h+1 } | |
end |
source: http://staffwww.dcs.shef.ac.uk/people/S.Chapman/stringmetrics.html currently implemented:
@Mori agreed. For those who don't want to invade String class here is my adaptation + usage https://gist.github.com/hakunin/5568313
@dingsdax Thanks for sharing the two implementations, helped me a lot!
Nice. But odd that these are instance methods that take two args. Shouldn't they be class methods that take two args, or instance methods that take one arg?