Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
15
Task/Man-or-boy-test/JavaScript/man-or-boy-test-1.js
Normal file
15
Task/Man-or-boy-test/JavaScript/man-or-boy-test-1.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
function a(k, x1, x2, x3, x4, x5) {
|
||||
function b() {
|
||||
k -= 1;
|
||||
return a(k, b, x1, x2, x3, x4);
|
||||
}
|
||||
return (k > 0) ? b() : x4() + x5();
|
||||
}
|
||||
|
||||
// this uses lambda wrappers around the numeric arguments
|
||||
function x(n) {
|
||||
return function () {
|
||||
return n;
|
||||
};
|
||||
}
|
||||
alert(a(10, x(1), x(-1), x(-1), x(1), x(0)));
|
||||
6
Task/Man-or-boy-test/JavaScript/man-or-boy-test-2.js
Normal file
6
Task/Man-or-boy-test/JavaScript/man-or-boy-test-2.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
var x = n => () => n;
|
||||
|
||||
var a = (k, x1, x2, x3, x4, x5) => {
|
||||
var b = () => return a(--k, b, x1, x2, x3, x4); //decrement k before use
|
||||
return (k > 0) ? b() : x4() + x5();
|
||||
};
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
function a(k, x1, x2, x3, x4, x5) {
|
||||
function b() {
|
||||
k = k - 1;
|
||||
return a(k, b, x1, x2, x3, x4);
|
||||
}
|
||||
return k <= 0 ? x4() + x5() : b();
|
||||
}
|
||||
|
||||
// this uses lambda wrappers around the numeric arguments
|
||||
function x(n) {
|
||||
return function () {
|
||||
return n;
|
||||
};
|
||||
}
|
||||
alert(a(10, x(1), x(-1), x(-1), x(1), x(0)));
|
||||
Loading…
Add table
Add a link
Reference in a new issue