How erlang just blew my mind


qsort([]) -> [];
qsort([Pivot|T]) -> qsort([X || X <- T, X < Pivot])
++ [Pivot] ++
qsort([X || X <- T, X >= Pivot]).


(taken from 'Programming Erlang' by the pragmatic programmers).

That's just...beautiful. Quicksort in 4 lines. Nothing extraneous, just the pure recursive algorithm.

Erlang is bending my mind, but that's okay...it needs a little kick every so often.

Comments

Popular posts from this blog

Review: The Southeast Christian Church Easter Pageant

Driving for the Cure...? (Or, how I got blacklisted...)

No, I don't have Connective Tissue Disorder