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,28 @@
(() => {
'use strict';
// factorial :: Int -> Int
const factorial = n =>
enumFromTo(1, n)
.reduce(product, 1);
const test = () =>
factorial(18);
// --> 6402373705728000
// GENERIC FUNCTIONS ----------------------------------
// product :: Num -> Num -> Num
const product = (a, b) => a * b;
// range :: Int -> Int -> [Int]
const enumFromTo = (m, n) =>
Array.from({
length: (n - m) + 1
}, (_, i) => m + i);
// MAIN ------
return test();
})();