diff --git a/Exercises/1-seq.js b/Exercises/1-seq.js index bdf0fe8..a4355ad 100644 --- a/Exercises/1-seq.js +++ b/Exercises/1-seq.js @@ -1,5 +1,9 @@ 'use strict'; -const seq = f => g => x => 0; +const seq = f => g => { + if (typeof g === 'number') + return f(g); + return seq(x => f(g(x))); +}; module.exports = { seq }; diff --git a/Exercises/2-array.js b/Exercises/2-array.js index b6d47cf..484f359 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 = i => arr[i]; + f.push = value => Array.prototype.push.call(arr, value); + f.pop = () => Array.prototype.pop.call(arr); + return f; +}; module.exports = { array };