all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,18 @@
|
|||
: insert ( start end -- start )
|
||||
dup @ >r ( r: v ) \ v = a[i]
|
||||
begin
|
||||
2dup < \ j>0
|
||||
while
|
||||
r@ over cell- @ < \ a[j-1] > v
|
||||
while
|
||||
cell- \ j--
|
||||
dup @ over cell+ ! \ a[j] = a[j-1]
|
||||
repeat then
|
||||
r> swap ! ; \ a[j] = v
|
||||
|
||||
: sort ( array len -- )
|
||||
1 ?do dup i cells + insert loop drop ;
|
||||
|
||||
create test 7 , 3 , 0 , 2 , 9 , 1 , 6 , 8 , 4 , 5 ,
|
||||
test 10 sort
|
||||
test 10 cells dump
|
||||
Loading…
Add table
Add a link
Reference in a new issue