September 2017
Beginner to intermediate
396 pages
9h 46m
English
So far, we have seen a simple recursion; recursion using worker pattern. Haskell adds laziness to the mix. We can use laziness to our advantage while working with recursion.
In this recipe, we will again calculate the fibonacci number. However, this time, we will do it with infinite lists. By taking advantage of Haskell's laziness to evaluate an expression only when it is required, we can really create a linear time algorithm (O(n)) for the fibonacci number.
Read now
Unlock full access