2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

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');
})();