This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function inc(x) { | |
return x + 1; | |
} | |
function count(f) { | |
return f(inc)(0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(count(input1)); // should print 1 | |
console.log(count(input2)); // should print 2 | |
console.log(count(input3)); // should print 10 | |
console.log(count(input4)); // should print 100 | |
console.log(count(input5)); // should print 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log(count(f(input1))); // should print 0 | |
console.log(count(f(input2))); // should print 1 | |
console.log(count(f(input3))); // should print 9 | |
console.log(count(f(input4))); // should print 99 | |
console.log(count(f(input5))); // should print 999 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
A task for inFullMobile Language Wars: Round 1 | |
TL;DR | |
We need a function f that takes a and returns b: | |
b = f(a) | |
when: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f(x) { | |
return function (y) { | |
return function (z) { | |
var r = z; | |
for (var i = 1; i++ < x(function (a) { return a + 1; })(0); r = y(r)); | |
return r; | |
}; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const f = x => y => z => { | |
let r = z; | |
for (let i = 1; i++ < x(a => a + 1)(0); r = y(r)); | |
return r; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function e(a) { | |
return function (b) { | |
return function (c) { | |
return c ? e(b(a))(b)(c - 1) : a; | |
}; | |
}; | |
} | |
function f(a) { | |
return function (b) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const e = a => b => c => c ? e(b(a))(b)(c - 1) : a; | |
const f = a => b => c => e(c)(b)(a(a => a + 1)(0) - 1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function f(a) { | |
return function (b) { | |
return function (c) { | |
return a(function (d) { | |
return function (e) { | |
return e(d(b)); | |
}; | |
})(function (f) { | |
return c; | |
})(function (g) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const f = a => b => c => a(d => e => e(d(b)))(f => c)(g => g); |