The Pragmatic Programmer(s) suggest learning a new language every year… when I was in college, it seemed that I was learning 2 or 3 languages a year: Scheme, Lisp, Ada, Fortran, C, IBM ASM, C++, Java, and MUMPS. The list kept growing… and since I’ve been out of college, I’ve picked up C# and Ruby.
I’m falling behind. So what’s the solution?
Time to learn Erlang… and guess what, the Pragmatic Programmers LLC has a book: Programming Erlang.
Wow, that was a mouthful. But yeah, it feels nice to go back to functional programming… double tail recursion, currying, and highly scalable parallel processing… all built into the language. Tastey.
So you might ask, let’s see some code!
qsort([]) -> [];
qsort([Pivot|T]) ->
qsort([X || X <- T, X < Pivot])
++ [Pivot] ++
qsort([X || X <- T, X >= Pivot]).
In which you would call it like this:
> L=[20,6,2,9,27,100,78,39,65,81,14].
[20,6,2,9,27,100,78,39,65,81,14]
> qsort(L).
[2,6,9,14,20,27,39,65,78,81,100]
There it is… the quick sort algorithm… Wow, quite impressive eh? I thought so…
geek.
Curious.