Skip to content

Instantly share code, notes, and snippets.

@ryu1-1uyr
Created April 3, 2019 07:40
Show Gist options
  • Save ryu1-1uyr/e3347d580feb1032d90aa3765a54f707 to your computer and use it in GitHub Desktop.
Save ryu1-1uyr/e3347d580feb1032d90aa3765a54f707 to your computer and use it in GitHub Desktop.
nanikasitai
const fib = (n) => {
return (n <= 2) ? 1 : (fib(n-1) + fib(n-2));
};
console.log(fib(10))
// (f => (n =>((n <= 2) ? 1 : (fib(n-1) + fib(n-2))) ))(10)
console.log(
(n => (n <= 2) ? 1 : (fib(n-1) + fib(n-2)) )(10)
);
// (function(f) {
// return function(n){
// return (n <= 2) ? 1 : (f(n-1) + f(n-2));
// };
// })()(10);
(f=>
(n=> (n <= 2) ? 1 : (f(n-1) + f(n-2)) )
)(x=>x)(10);
// (function(f) { // ← ここに外の関数を入れた
// return f(/* ここに中の関数を入れられれば */)
// })(function(f) { // ← ここに中の関数が入ってくるはず
// return function(n){
// return (n <= 2) ? 1 : (f(n-1) + f(n-2));
// };
// })(10);
//動かないf()に関数を仕込めればそこが動く?
// (f => f())(f =>n => (n <= 2) ? 1 : (f(n-1) + f(n-2)) )
// (function(f) { // この関数は f に「中の関数」を入れれば、「中の関数」を返す
// return function g(m) { // ↑が成り立つと ↓ の f も「中の関数」を返す
// return f(g)(m);
// };
// })(function(f) {
// return function(n){
// return (n <= 2) ? 1 : (f(n-1) + f(n-2));
// };
// })(10);
console.log((f => {
return (g = m => {
return f(g)(m)
})
})(
(f => {
return (n=> {
return (n <= 2) ? 1 : (f(n-1) + f(n-2))
})
})
)(10));
// (function(f) {
// return function g(m) {
// return f(g)(m);
// };
// })(function(f) {
// return function(n){
// return (n <= 2) ? 1 : (f(n-1) + f(n-2));
// };
// })(10);
console.log(
(f=> (g = (m => (f(g)(m)) )))
(f=> (n=> ((n <= 2) ? 1 : (f(n-1) + f(n-2)))))
(10)
);
// console.log((f => {
// return (g => {
// return (m => {
// return f(g)(m)
// })
// })
// })(
// (f => {
// return (n=> {
// return (n <= 2) ? 1 : (f(n-1) + f(n-2))
// })
// })
// )(10)
//
// );
// console.log(
// (f=> (g=> (m => ( f(g(g))(m) ) )))
// (f=> (n=> ((n <= 2) ? 1 : (f(n-1) + f(n-2)))))
// (10)
// );
//
(function(f) {
return (function(g) {
return function(m) {
return f(g(g))(m);
};
})(function(g) {
return function(m) {
return f(g(g))(m);
};
})
})(function(f) {
return function(n){
return (n <= 2) ? 1 : (f(n-1) + f(n-2));
};
})(10);
console.log(
(f => (g => m => (f(g(g))(m)))
(g => m => (f(g(g))(m))))
(f => (n => ((n <= 2) ? 1 : (f(n-1) + f(n-2)) ) ))(10)
);
// (f => (p => f(a => (p(p))(a)))
// (p => f(a => (p(p))(a)))
// )
// (n => (str => (x=>x||n)(n % 5 ? str : `${str}Buzz`))((str => n % 3 ? str : `${str}Fizz`)("")))
console.log(
(f => (g => m => (f(g(g))(m)))
(g => m => (f(g(g))(m)))
)
(f =>
(n => (str => (x=>console.log(x||n))(n % 5 ? str : `${str}Buzz`))((str => n % 3 ? str : `${str}Fizz`)("")))
)(12)
);
const loop = b => e => f => {
if (b <= e) {
f(b)
loop(b+1)(e)(f)
}
}
loop(1)(31)(
(f => (g => m => (f(g(g))(m)))
(g => m => (f(g(g))(m)))
)
(f =>
(n => (str => (x=>console.log(x||n))(n % 5 ? str : `${str}Buzz`))((str => n % 3 ? str : `${str}Fizz`)("")))
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment