Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,14 @@
var k2c = k => k - 273.15
var k2r = k => k * 1.8
var k2f = k => k2r(k) - 459.67
Number.prototype.toMaxDecimal = function (d) {
return +this.toFixed(d) + ''
}
function kCnv(k) {
document.write( k,'K° = ', k2c(k).toMaxDecimal(2),'C° = ', k2r(k).toMaxDecimal(2),'R° = ', k2f(k).toMaxDecimal(2),'F°<br>' )
}
kCnv(21)
kCnv(295)

View file

@ -0,0 +1,38 @@
(() => {
'use strict';
let kelvinTranslations = k => ['K', 'C', 'F', 'R']
.map(x => [x, heatBabel(k, 'K', x)]);
// heatBabel :: Num -> ScaleName -> ScaleName -> Num
let heatBabel = (n, strFromScale, strToScale) => {
let ratio = 9 / 5,
cels = 273.15,
fahr = 459.67,
id = x => x,
readK = {
k: id,
c: x => cels + x,
f: x => (fahr + x) * ratio,
r: x => x / ratio
},
writeK = {
k: id,
c: x => x - cels,
f: x => (x * ratio) - fahr,
r: x => ratio * x
};
return writeK[strToScale.charAt(0).toLowerCase()](
readK[strFromScale.charAt(0).toLowerCase()](n)
).toFixed(2);
};
// TEST
return kelvinTranslations(21)
.map(([s, n]) => s + (' ' + n)
.slice(-10))
.join('\n');
})();