Sorting algorithms/Bubble sort: Difference between revisions

→‎{{header|Scheme}}: The first function is not iterative. The two versions are actually equal.
(→‎{{header|Scheme}}: Fix formatting, simplified, better variable names)
(→‎{{header|Scheme}}: The first function is not iterative. The two versions are actually equal.)
Line 2,329:
(fix sort-step x)))</lang>
 
This solution iterativelyrecursively finds the fixed point of sort-step. A comparison function must be passed to bubblesort. Example usages:
<lang scheme>(bubble-sort (list 1 3 5 9 8 6 4 2) >)
(bubble-sort (string->list "Monkey") char<?)</lang>
 
Here is athe recursivesame bubble sort which sorts list 'l'function, using thea comparatordifferent 'f'syntax:
 
<lang scheme>(define (bsort l gt?)
Anonymous user