Sorting algorithms/Comb sort: Difference between revisions

Content added Content deleted
Line 773: Line 773:


\ compute a new gap using scaled division
\ compute a new gap using scaled division
\ factored out for this example. Should be a macro or inline code.
\ factored out for this example. Could be a macro or inline code.
: /1.3 ( n -- n' ) 10 13 */ ;
: /1.3 ( n -- n' ) 10 13 */ ;


\ factored out for this example. Should be a macro or inline code.
\ factored out for this example. Could be a macro or inline code.
: XCHG ( adr1 adr2 n1 n2-- ) SWAP ROT ! SWAP ! ;
: XCHG ( adr1 adr2 n1 n2-- ) SWAP ROT ! SWAP ! ;


Line 799: Line 799:
SORTED @ GAP @ 0= AND \ test for complete
SORTED @ GAP @ 0= AND \ test for complete
UNTIL
UNTIL
R> DROP ;</lang>
R> DROP ; \ remove 'n' from return stack </lang>


=={{header|Fortran}}==
=={{header|Fortran}}==