Archive

Quick Sort

I took this example from Joe Armstrong’s book: Programming Erlang to show the beauty Erlang in recursion. Classic example of quick sort implementation

Can’t believe it, 6 simple and very elegant!!! I remembered roughly 10 years ago, how hard to write quick sort implementation in Pascal.

Tail Recursion

The quick sort implementation above is not tail recursive way. As the function call doesn’t return the whole results at once (look at the list concatenation). Here are few examples of tail recursion in Erlang