Sorting algorithms/Comb sort: Difference between revisions
Content added Content deleted
(Add Common Lisp implementation) |
m (minor edits) |
||
Line 465: | Line 465: | ||
(loop with input-size = (length input) |
(loop with input-size = (length input) |
||
with gap = input-size |
with gap = input-size |
||
with swapped |
with swapped |
||
⚫ | |||
do (when (> gap 1) |
do (when (> gap 1) |
||
(setf gap (floor gap *shrink*))) |
(setf gap (floor gap *shrink*))) |
||
(setf swapped nil) |
(setf swapped nil) |
||
(loop for lo from 0 |
(loop for lo from 0 |
||
for hi |
for hi from gap below input-size |
||
do (when (> (aref input lo) (aref input hi)) |
do (when (> (aref input lo) (aref input hi)) |
||
(rotatef (aref input lo) (aref input hi)) |
(rotatef (aref input lo) (aref input hi)) |
||
(setf swapped t |
(setf swapped t))) |
||
⚫ | |||
input)</lang> |
|||
finally (return input)))</lang> |
|||
=={{header|D}}== |
=={{header|D}}== |