From 4005574bb2ea3792dea248adb4c13c22dc96cd38 Mon Sep 17 00:00:00 2001 From: Orbis Date: Fri, 31 Dec 2021 13:25:25 +0300 Subject: [PATCH] homework --- Exercises/1-seq.js | 2 +- Exercises/2-array.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Exercises/1-seq.js b/Exercises/1-seq.js index 0cc00a7..b6bfa0e 100644 --- a/Exercises/1-seq.js +++ b/Exercises/1-seq.js @@ -1,5 +1,5 @@ 'use strict'; -const seq = (f) => (g) => (x) => 0; +const seq = (f) => (n) => (typeof n === 'number' ? f(n) : seq((a) => f(n(a)))); module.exports = { seq }; diff --git a/Exercises/2-array.js b/Exercises/2-array.js index b6d47cf..4336da3 100644 --- a/Exercises/2-array.js +++ b/Exercises/2-array.js @@ -1,5 +1,11 @@ 'use strict'; -const array = () => null; +const array = () => { + const arr = []; + const f = (a) => arr[a]; + f['push'] = (a) => arr.push(a); + f['pop'] = (a) => arr.pop(a); + return f; +}; module.exports = { array };