code style Update Phpml\Math\Distance\Manhattan::distance() method. (#154)

I think this will be better.
This commit is contained in:
Qingshan Luo 2017-11-17 04:45:35 +08:00 committed by Arkadiusz Kondas
parent f7537c049a
commit ff80af2044

View File

@ -18,13 +18,8 @@ class Manhattan implements Distance
throw InvalidArgumentException::arraySizeNotMatch(); throw InvalidArgumentException::arraySizeNotMatch();
} }
$distance = 0; return array_sum(array_map(function ($m, $n) {
$count = count($a); return abs($m - $n);
}, $a, $b));
for ($i = 0; $i < $count; ++$i) {
$distance += abs($a[$i] - $b[$i]);
}
return $distance;
} }
} }