Functional Programming – QuickSort and Fibonacci (Memoization)

The above is a nice session video which talks about the Ruby’s functional programming aspect, by comparing it with Haskell. There’re many topics are covered, but I found interesting about the quick sort and fibonacci examples.

QuickSort

I tried with similar approach on Elixir as follows. They’re concise and intuitive with the power of functional programming language, nice.

Fibonacci (Memoization)

At around 35:29, Haskell memorization is described. I knew the term “memoization” previously, but didn’t know much about its meaning. After learning the functional languages, I’m getting to understand the concept of the no-side-effects and the purpose of the memoization.

The memoization is described in here (http://www.haskell.org/haskellwiki/Memoization). I haven’t been able to fully understand them, but the concept of remembering/reusing the function inputs/outputs along with the lazy evaluation sounds interesting.

Elixir has “Stream” for lazy evaluation, as similar way as Ruby. As it’s not natively integrated as much as Haskell, it requires to separately store the calculation results for memoization. The following has nice discussion and some example codes on this topic.