Sigma@sigmasternchen@comfy.social
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, limit) => {
    console.log(from);
    if (limit > 1) count(from + 1, limit -1);
};
count(0, 10);

???

((f,l)=>
    (f=>(g=>f(h=>g(g)(h)))(g=>f(h=>g(g)(h))))(
        c=>([f,l])=>console.log(f)??l>1?c([f+1,l-1]):null
    )([f,l])
)(0, 10)
❤4
1 1 4

불러오는 중…