From 20caa05f1b9ec6c422c9a557d4c56037a1767991 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Wed, 11 Oct 2017 20:47:50 -0400 Subject: [PATCH] lib/vsm: access to non-existing keys return 0.0 Signed-off-by: Alexandre Terrasa --- lib/vsm/vsm.nit | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/vsm/vsm.nit b/lib/vsm/vsm.nit index 41d5152..8eaeca8 100644 --- a/lib/vsm/vsm.nit +++ b/lib/vsm/vsm.nit @@ -72,6 +72,11 @@ class Vector return cos end + redef fun [](k) do + if not has_key(k) then return 0.0 + return super + end + # The norm of the vector. # # `||x|| = (x1 ** 2 ... + xn ** 2).sqrt` -- 1.7.9.5