Sorting algorithms/Quicksort: Difference between revisions
Content added Content deleted
(Notes about the Fortran algorithm being flawed and a pointer to a better one.) |
|||
Line 5,610: | Line 5,610: | ||
val ys = xx.filter fn(el) { el < x } |
val ys = xx.filter fn(el) { el < x } |
||
val zs = xx.filter fn(el) { el >= x } |
val zs = xx.filter fn(el) { el >= x } |
||
qsort(ys) + [x] + qsort(zs) |
qsort(ys) ++ [x] ++ qsort(zs) |
||
} |
} |
||
Nil -> Nil |
Nil -> Nil |
||
Line 5,621: | Line 5,621: | ||
Cons(x,xx) -> { |
Cons(x,xx) -> { |
||
val (ys, zs) = xx.partition fn(el) { el < x } |
val (ys, zs) = xx.partition fn(el) { el < x } |
||
qsort(ys) + [x] + qsort(zs) |
qsort(ys) ++ [x] ++ qsort(zs) |
||
} |
} |
||
Nil -> Nil |
Nil -> Nil |