Sorting algorithms/Insertion sort: Difference between revisions

Added Qi
(from the wikipedia -> from wikipedia)
(Added Qi)
Line 1,053:
{InsertionSort Arr}
{Show {Array.toRecord unit Arr}}</lang>
 
=={{header|Qi}}==
Based on the scheme version.
<lang qi>(define insert
X [] -> [X]
X [Y|Ys] -> [X Y|Ys] where (<= X Y)
X [Y|Ys] -> [Y|(insert X Ys)])
 
(define insertion-sort
[] -> []
[X|Xs] -> (insert X (insertion-sort Xs)))
 
(insertion-sort [6 8 5 9 3 2 1 4 7])
</lang>
 
=={{header|PARI/GP}}==
Anonymous user