"use strict";
+function near(a, b, epsilon = 1e-6) {
+ return Math.abs(a - b) < epsilon;
+}
+
+function less_than_or_near(a, b, epsilon = 1e-6) {
+ return a < b || near(a, b, epsilon);
+}
+
function parse_table(as_text) {
function parse_line(line) {
return line.trim().split(' ').filter(x => x !== '').map(x => parseFloat(x));
});
return function(net) {
for (const [start, end, m, b] of inverse_table) {
- if (start <= net && net <= end) {
+ if (less_than_or_near(start, net) && less_than_or_near(net, end)) {
return (net - b) / m;
}
}
f();
}
-function near(a, b, epsilon = 1e-6) {
- return Math.abs(a - b) < epsilon;
-}
-
function rand(limit = 99) {
return Math.round(Math.random() * limit);
}