Sorting algorithms/Comb sort: Difference between revisions
Content added Content deleted
(Added PicoLisp) |
|||
Line 683: | Line 683: | ||
return $arr; |
return $arr; |
||
}</lang> |
}</lang> |
||
=={{header|PicoLisp}}== |
|||
<lang PicoLisp>(de combSort (Lst) |
|||
(let (Gap (length Lst) Swaps NIL) |
|||
(while (or (> Gap 1) Swaps) |
|||
(setq Gap (max 1 (/ (* Gap 4) 5))) |
|||
(off Swaps) |
|||
(use Lst |
|||
(for (G (cdr (nth Lst Gap)) G (cdr G)) |
|||
(when (> (car Lst) (car G)) |
|||
(xchg Lst G) |
|||
(on Swaps) ) |
|||
(pop 'Lst) ) ) ) ) |
|||
Lst )</lang> |
|||
Output: |
|||
<pre>: (combSort (88 18 31 44 4 0 8 81 14 78 20 76 84 33 73 75 82 5 62 70)) |
|||
-> (0 4 5 8 14 18 20 31 33 44 62 70 73 75 76 78 81 82 84 88)</pre> |
|||
=={{header|PL/I}}== |
=={{header|PL/I}}== |
||
<lang PL/I> |
<lang PL/I> |