Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,17 @@
|
|||
procedure main() #: demonstrate various ways to sort a list and string
|
||||
demosort(cocktailsort,[3, 14, 1, 5, 9, 2, 6, 3],"qwerty")
|
||||
end
|
||||
|
||||
procedure cocktailsort(X,op) #: return sorted list
|
||||
local i,swapped
|
||||
|
||||
op := sortop(op,X) # select how and what we sort
|
||||
|
||||
swapped := 1
|
||||
repeat # translation of pseudo code. Contractions used to eliminate second loop.
|
||||
every (if /swapped then break break else swapped := &null & next) | ( i := 1 to *X-1) |
|
||||
(if /swapped then break break else swapped := &null & next) | ( i := *X-1 to 1 by -1) do
|
||||
if op(X[i+1],X[i]) then
|
||||
X[i+1] :=: X[swapped := i]
|
||||
return X
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue