From 43545a980fd96467ffb1ab4267c199a17184e743 Mon Sep 17 00:00:00 2001 From: ShiroganeIXV Date: Tue, 2 Apr 2024 13:30:53 +0700 Subject: [PATCH] Add shiroganeIXV_solutions --- Solutions/shiroganeIXV_solutions.js | 136 ++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 Solutions/shiroganeIXV_solutions.js diff --git a/Solutions/shiroganeIXV_solutions.js b/Solutions/shiroganeIXV_solutions.js new file mode 100644 index 0000000..bdd0b9a --- /dev/null +++ b/Solutions/shiroganeIXV_solutions.js @@ -0,0 +1,136 @@ + +function identity(x) { + return x; +} + +function addb(a, b) { + return a + b; +} + +function subb(a, b) { + return a - b; +} + +function mulb(a, b) { + return a * b; +} + +function minb(a, b) { + return Math.min(a, b); +} + +function maxb(a, b) { + return Math.max(a, b); +} + +function add(...nums) { + return nums.reduce((acc, curr) => acc + curr); +} + +function sub(...nums) { + return nums.reduce((acc, curr) => acc - curr); +} + +function mul(...nums){ + return nums.reduce((acc, curr) => acc * curr); +} + +function min(...nums) { + return Math.min(...nums); +} + +function max(...nums) { + return Math.max(...nums); +} + + +function addRecurse(...nums) { + if (nums.length === 1) { + return nums[0]; + } + return nums[0] + addRecurse(...nums.slice(1)); // will give you all the elements of the nums array except for the first one +} + +module.exports = { + identity, + addb, + subb, + mulb, + minb, + maxb, + add, + sub, + mul, + min, + max, + addRecurse, + /* + mulRecurse, + minRecurse, + maxRecurse, + not, + acc, + accPartial, + accRecurse, + fill, + fillRecurse, + set, + identityf, + addf, + liftf, + pure, + curryb, + curry, + inc, + twiceUnary, + doubl, + square, + twice, + reverseb, + reverse, + composeuTwo, + composeu, + composeb, + composeTwo, + compose, + limitb, + limit, + genFrom, + genTo, + genFromTo, + elementGen, + element, + collect, + filter, + filterTail, + concatTwo, + concat, + concatTail, + gensymf, + gensymff, + fibonaccif, + counter, + revocableb, + revocable, + extract, + m, + addmTwo, + addm, + liftmbM, + liftmb, + liftm, + exp, + expn, + addg, + liftg, + arrayg, + continuizeu, + continuize, + vector, + exploitVector, + vectorSafe, + pubsub, + mapRecurse, + filterRecurse, + */ +}; \ No newline at end of file