--00032555145ac8e787049a3ffe53
Content-Type: text/plain; charset=ISO-8859-1

Unsubscribe
On Jan 18, 2011 8:56 PM, "dblock" <dblockdotorg / gmail.com> wrote:
> I am trying to improve performance of Euclidian distance between two
> hash maps. The code is pretty straightforward:
>
> def self.euclidian_distance(lhs, rhs)
> @s  hs.inject(0.0) do |s, (k,v)|
> rhs.has_key?(k) ? (s + (v - rhs[k])**2) : (s + v**2)
> end
> @s  hs.inject(@s) do |s, (k,v)|
> lhs.has_key?(k) ? s : (s + v**2)
> end
> @s
> end
>
> Any suggestions?
>

--00032555145ac8e787049a3ffe53--