Skip to content

Instantly share code, notes, and snippets.

View SunskyXH's full-sized avatar
:bowtie:
be happy

SunskyXH SunskyXH

:bowtie:
be happy
View GitHub Profile
@SunskyXH
SunskyXH / qsort.re
Created December 17, 2017 05:23
quick sort in reason
let rec quicksort = (gt) =>
fun
| [] => []
| [x, ...xs] => {
let (ys, zs) = List.partition(gt(x), xs);
quicksort(gt, ys) @ [x, ...quicksort(gt, zs)]
};
@SunskyXH
SunskyXH / qsort.js
Created July 8, 2017 08:06
quick sort in ES6
let qsort = list => {
if (list.length === 0) return [];
let [x, ...xs] = list;
return [...qsort(xs.filter(u => u <= x)),
x, ...qsort(xs.filter(u => u > x))]
};