Liuw's Thinkpad

想要赢就先学会输,想要成功就先学会失败

Archive for the ‘quick sort’ tag

Quick Sort in Erlang

without comments

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

用到了list comprehension,很好的功能。

Written by liuw

June 22nd, 2009 at 10:29 pm

Posted in Algorithm,Programming

Tagged with ,