Counting for ~~Dummies~~ Programmers:
Imperative:
for(let i = 0; i < 10; ++i) {
console.log(i);
}
Declarative:
const range = (from, to) => [...Array(to - from).keys().map(i => i + from)];
range(0, 10).forEach(i => console.log(i));
Recursion:
const count = (from, to) => {
console.log(from);
if (to > 1) count(from + 1, to -1);
};
count(0, 10);
???
((f,t)=>
(f=>(g=>f(h=>g(g)(h)))(g=>f(h=>g(g)(h))))(
c=>([f,t])=>console.log(f)??t>1?c([f+1,t-1]):null
)([f,t])
)(0, 10)
Comments
Displaying 0 of 0 comments