all tasks

This commit is contained in:
Ingy döt Net 2013-04-11 01:07:29 -07:00
parent b83f433714
commit 68f8f3e56b
14735 changed files with 178959 additions and 0 deletions

View file

@ -0,0 +1,22 @@
procedure main() #: demonstrate various ways to sort a list and string
demosort(combsort,[3, 14, 1, 5, 9, 2, 6, 3],"qwerty")
end
procedure combsort(X,op) #: return sorted X
local gap,swapped,i
op := sortop(op,X) # select how and what we sort
swappped := gap := *X # initialize gap size and say swapped
until /swapped & gap = 1 do {
gap := integer(gap / 1.25) # update the gap value for a next comb
gap <:= 1 # minimum gap of 1
swapped := &null
i := 0
until (i +:= 1) + gap > *X do # a single "comb" over the input list
if op(X[i+gap],X[i]) then
X[i+1] :=: X[swapped := i] # swap and flag as unsorted
}
return X
end