News for hackers. Stuff that matters.
Re:When Functional Programming Isn't Functional by kangoo1707 on Monday April 02, 2018 @02:27AM (#16732734)
The two versions that you give do not return the same thing. the FP one returns a list, while the imperative one returns a number
Re:When Functional Programming Isn't Functional by archgoon on Monday April 02, 2018 @03:12AM (#16732875)
Yes, but that's another issue with the article. Modifying the first to return a list though is trivial, you declare an List at the beginning and then you append in the for loop.