Sorting algorithms/Bubble sort: Difference between revisions

Added Qi
(→‎{{header|Scheme}}: The first function is not iterative. The two versions are actually equal.)
(Added Qi)
Line 2,076:
bubble_sort(testcase)
assert testcase == testset # we've unshuffled it back into a copy</lang>
 
 
=={{header|Qi}}==
<lang Qi>(define bubble-shot
[A] -> [A]
[A B|R] -> [B|(bubble-shot [A|R])] where (> A B)
[A |R] -> [A|(bubble-shot R)])
 
(define bubble-sort
X -> X where (= X (bubble-shot X))
X -> (bubble-sort (bubble-shot X)))
 
(bubble-sort [6 8 5 9 3 2 2 1 4 7])
</lang>
 
=={{header|R}}==
Anonymous user