From 779463072d489b899a7421ca2e0b6547111c7512 Mon Sep 17 00:00:00 2001 From: rolux Date: Tue, 3 Dec 2013 20:57:00 +0100 Subject: [PATCH] make Ox.hypot n-ary --- source/Ox/js/Math.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/Ox/js/Math.js b/source/Ox/js/Math.js index fe25bab2..9e933c04 100644 --- a/source/Ox/js/Math.js +++ b/source/Ox/js/Math.js @@ -58,9 +58,10 @@ Ox.hypot Returns the square root of the sum of the squares of its arguments > Ox.hypot(1, 1, 1) Math.sqrt(3) @*/ -Ox.hypot = function(x, y, z) { - z = z || 0; - return Math.sqrt(x * x + y * y + z * z) || 0; +Ox.hypot = function() { + return Math.sqrt(Ox.slice(arguments).reduce(function(sum, number) { + return sum + number * number; + }, 0)); }; /*@