Snippets has posted 5883 posts at DZone. View Full User Profile
// Calculates the Euclidean distance between two vectors (arrays) in Ruby
def euclidean_distance(vector1, vector2)
sum = 0
vector1.zip(vector2).each do |v1, v2|
component = (v1 - v2)**2
sum += component
DZone's 170th Refcard is an essential reference to Camel, an open-source, lightweight, integration library. This Refcard is authored by...