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

불러오는 중…

ελΥ.𐤍@elyn@tech.lgbt
re: Counting for ~~Dummies~~ Programmers:펼치기

@sigmasternchen definitely, yeah!! I'd say my "first love", so to say, is pure mathematics, but I went into studying computer science cuz it felt adjacent while having the potential for remote work. And then as I went into it, I've come to actually get into it, especially functional and declarative patterns on account of them feeling truer to the underlying mathematical structures that motivate the code