Break the Loop, Part 3: When the Shape of the Answer Becomes the Program

https://hackernoon.imgix.net/images/sySM3ByE40PpGfuUTKKlXrkVuUL2-y233b9f.png

Diving into functional programming (hereafter FP) is not just interesting. Step by step, I personally discovered how data influences the algorithms that process it (Part 1), and how the shape of a function governs computation (Part 2).

I will be honest: my imperative background still makes itself felt. Even though we agreed to work within a computational model where memory is immutable, expressions are evaluated via substitution, recursion is used instead of loops, and a program is not executed but reduced to a result.

In this part, I will show how properly formulated requirements for the result reveal FP at its best.

Task 8: Finding the Maximum Using Tail Recursion

(task numbering continues from Part 1)

It just so happened that finding the maximum value in a list has become an invariant of this series of articles. In Part 1, it was implemented as a partial...

Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE