Anonymous user
Sorting algorithms/Bubble sort: Difference between revisions
m
→{{header|REXX}}: changed/added comments and whitespace, changed indentations.
(Updated with a simpler example of Julia implementation) |
m (→{{header|REXX}}: changed/added comments and whitespace, changed indentations.) |
||
Line 3,320:
=={{header|REXX}}==
<lang rexx>/*REXX program sorts an array (of any kind of items) using the bubble-sort algorithm.*/
call gen /*generate the array elements (items).*/
call show 'before sort' /*show the before array elements. */
say copies('─', 79) /*show a separator line (before/after).*/
call bubbleSort # /*invoke the bubble sort with # items.*/
call show ' after sort' /*show the after array elements. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
bubbleSort: procedure expose @.; parse arg n; m=n-1 /*N: number of array elements. */
end
@.k=_ /* ··· and the next with _ */▼
/*──────────────────────────────────────────────────────────────────────────────────────*/
gen: @.=; @.1 = '---letters of the Hebrew alphabet---' ; @.13= "kaph [kaf]"
end /* (1≡true, 0≡false). */▼
▲ end /*j*/
▲ @.2 = '====================================' ; @.14 = 'lamed'
@.
▲ @.8 = 'waw [vav]' ; @.20 = 'sadhe [tsadi]'
▲ @.10 = 'heth [het]' ; @.22 = 'resh'
return
/*──────────────────────────────────────────────────────────────────────────────────────*/
show: w=length(#); do j=1 for #;
'''output''' when using the internal array list:
<pre style="height:30ex">
|