From 2445fd382a0b5d592fd6790137915f591abe63b1 Mon Sep 17 00:00:00 2001 From: Maks3105 Date: Thu, 2 May 2024 22:43:07 +0700 Subject: [PATCH] TASKS 1,2 --- Exercises/1-seq.js | 4 +++- Exercises/2-array.js | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Exercises/1-seq.js b/Exercises/1-seq.js index 0cc00a7..7530a54 100644 --- a/Exercises/1-seq.js +++ b/Exercises/1-seq.js @@ -1,5 +1,7 @@ 'use strict'; -const seq = (f) => (g) => (x) => 0; +const seq = (outFn) => (inFn) => (typeof inFn === 'number' ? + outFn(inFn) : + seq((x) => outFn(inFn(x)))); module.exports = { seq }; diff --git a/Exercises/2-array.js b/Exercises/2-array.js index b6d47cf..5d0539c 100644 --- a/Exercises/2-array.js +++ b/Exercises/2-array.js @@ -1,5 +1,13 @@ 'use strict'; -const array = () => null; +const array = () => { + const someArray = []; + const get = (x) => someArray[x]; + + get.push = (x) => someArray.push(x); + get.pop = () => someArray.pop(); + + return get; +}; module.exports = { array };