From b6549da39c28c5294aa26bcf21748ac70b176038 Mon Sep 17 00:00:00 2001 From: elidiany Date: Wed, 30 Mar 2022 12:53:02 +0900 Subject: [PATCH] Labs done --- Exercises/1-seq.js | 2 +- Exercises/2-array.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Exercises/1-seq.js b/Exercises/1-seq.js index 0cc00a7..48ab441 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) => (g) => (typeof g === 'number' ? f(g) : seq((x) => f(g(x)))); module.exports = { seq }; diff --git a/Exercises/2-array.js b/Exercises/2-array.js index b6d47cf..a116bd0 100644 --- a/Exercises/2-array.js +++ b/Exercises/2-array.js @@ -1,5 +1,10 @@ 'use strict'; -const array = () => null; +const array = () => { + const data = []; + const get = (i) => data[i]; + get.push = (x) => data.push(x); + get.pop = () => data.pop(); +}; module.exports = { array };