all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
|
|
@ -0,0 +1,19 @@
|
|||
procedure main() #: demonstrate various ways to sort a list and string
|
||||
demosort(gnomesort,[3, 14, 1, 5, 9, 2, 6, 3],"qwerty")
|
||||
end
|
||||
|
||||
procedure gnomesort(X,op) #: return sorted list
|
||||
local i,j
|
||||
|
||||
op := sortop(op,X) # select how and what we sort
|
||||
|
||||
j := (i := 2) + 1 # translation of pseudo code
|
||||
while i <= *X do {
|
||||
if op(X[i],X[i-1]) then {
|
||||
X[i] :=: X[i -:= 1]
|
||||
if i > 1 then next
|
||||
}
|
||||
j := (i := j) + 1
|
||||
}
|
||||
return X
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue