Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In the example in question, the author compares apples to oranges: an imperative iterative Fibonacci print-first-n-fibs vs. a functional recursive Fibonacci return-nth-fib. An imperative recursive Fibonacci return-nth-fib would be far closer to classical mathematical notation.

A good way to cut through the ideological BS is to look at how mathematicians write pseudo-code. It's almost always either pure imperative, or imperative with a tiny smattering of OOP/FP stuff (no thicker than you'd see in a sophisticated C project).



    int fib(int n)
    {
    	return (n <= 1) ? n : fib(n-1) + fib(n-2);
    }




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: