Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -0,0 +1,16 @@
|
|||
StoogeSort(L, i:=1, j:=""){
|
||||
if !j
|
||||
j := L.MaxIndex()
|
||||
if (L[j] < L[i]){
|
||||
temp := L[i]
|
||||
L[i] := L[j]
|
||||
L[j] := temp
|
||||
}
|
||||
if (j - i > 1){
|
||||
t := floor((j - i + 1)/3)
|
||||
StoogeSort(L, i, j-t)
|
||||
StoogeSort(L, i+t, j)
|
||||
StoogeSort(L, i, j-t)
|
||||
}
|
||||
return L
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
MsgBox % map(StoogeSort([123,51,6,73,3,-12,0]))
|
||||
return
|
||||
|
||||
map(obj){
|
||||
for k, v in obj
|
||||
res .= v ","
|
||||
return trim(res, ",")
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ class
|
|||
STOOGE_SORT
|
||||
feature
|
||||
stoogesort (ar: ARRAY[INTEGER]; i,j: INTEGER)
|
||||
-- Sorted array in ascending order.
|
||||
require
|
||||
ar_not_empty: ar.count >= 0
|
||||
i_in_range: i>=1
|
||||
|
|
|
|||
|
|
@ -1,20 +1,32 @@
|
|||
class
|
||||
APPLICATION
|
||||
inherit
|
||||
ARGUMENTS
|
||||
|
||||
create
|
||||
make
|
||||
feature
|
||||
make
|
||||
do
|
||||
test:= <<2,5,66,-2, 0, 7>>
|
||||
io.put_string ("%Nunsorted:%N")
|
||||
across test as ar loop io.put_string (ar.item.out + "%T") end
|
||||
create stoogesort
|
||||
stoogesort.stoogesort (test, 1, test.count)
|
||||
io.put_string ("%Nsorted:%N")
|
||||
across test as ar loop io.put_string (ar.item.out + "%T") end
|
||||
end
|
||||
test: ARRAY[INTEGER]
|
||||
|
||||
feature
|
||||
|
||||
make
|
||||
do
|
||||
test := <<2, 5, 66, -2, 0, 7>>
|
||||
io.put_string ("%Nunsorted:%N")
|
||||
across
|
||||
test as ar
|
||||
loop
|
||||
io.put_string (ar.item.out + "%T")
|
||||
end
|
||||
create stoogesort
|
||||
stoogesort.stoogesort (test, 1, test.count)
|
||||
io.put_string ("%Nsorted:%N")
|
||||
across
|
||||
test as ar
|
||||
loop
|
||||
io.put_string (ar.item.out + "%T")
|
||||
end
|
||||
end
|
||||
|
||||
test: ARRAY [INTEGER]
|
||||
|
||||
stoogesort: STOOGE_SORT
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue