September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -1,7 +1,30 @@
console.log(
(() => {
[5, 50, 9000].map(function (n) {
return (n).toString(2);
}).join('\n')
// showIntAtBase_ :: // Int -> Int -> String
const showIntAtBase_ = (base, n) => (n)
.toString(base);
)
// showBin :: Int -> String
const showBin = n => showIntAtBase_(2, n);
// GENERIC FUNCTIONS FOR TEST ---------------------------------------------
// intercalate :: String -> [a] -> String
const intercalate = (s, xs) => xs.join(s);
// map :: (a -> b) -> [a] -> [b]
const map = (f, xs) => xs.map(f);
// unlines :: [String] -> String
const unlines = xs => xs.join('\n');
// show :: a -> String
const show = x => JSON.stringify(x);
// TEST -------------------------------------------------------------------
return unlines(map(
n => intercalate(' -> ', [show(n), showBin(n)]),
[5, 50, 9000]
));
})();