This commit is contained in:
Roman Galochkin 2020-02-21 17:05:42 +03:00
parent 3de54bee23
commit b0cc498b07
2 changed files with 12 additions and 1 deletions

View File

@ -5,3 +5,9 @@ let interpolate =
let maxProportion = (xIntended -. xMin) /. (xMax -. xMin);
yMin *. minProportion +. yMax *. maxProportion;
};
/* https://bucklescript.github.io/bucklescript/api/Belt.html */
let sum = Belt.Array.reduce(_, 0., (i, j) => i +. j);
let mean = a => sum(a) /. (Array.length(a) |> float_of_int);
let min = Belt.Array.reduce(_, 0., (i, j) => i < j ? i : j);
let max = Belt.Array.reduce(_, 0., (i, j) => i > j ? i : j);

View File

@ -1,4 +1,5 @@
/**
* @Done
* @param {number} xMin
* @param {number} xMax
* @param {number} yMin
@ -50,6 +51,7 @@ function range(min, max, n) {
}
/**
* @Done
* @param {number[]} arr
* @return {number}
*/
@ -58,6 +60,7 @@ function sum(arr) {
}
/**
* @Done
* @param {number[]} arr
* @return {number}
*/
@ -66,6 +69,7 @@ function mean(arr) {
}
/**
* @Done
* @param {number[]} arr
* @return {number}
*/
@ -80,6 +84,7 @@ function min(arr) {
}
/**
* @Done
* @param {number[]} arr
* @return {number}
*/
@ -133,4 +138,4 @@ module.exports = {
random,
up,
down,
};
};