aboutsummaryrefslogtreecommitdiff
path: root/src/algebra/sortpak.spad.pamphlet
diff options
context:
space:
mode:
Diffstat (limited to 'src/algebra/sortpak.spad.pamphlet')
-rw-r--r--src/algebra/sortpak.spad.pamphlet24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/algebra/sortpak.spad.pamphlet b/src/algebra/sortpak.spad.pamphlet
index 2d10ddf3..c96e3aa1 100644
--- a/src/algebra/sortpak.spad.pamphlet
+++ b/src/algebra/sortpak.spad.pamphlet
@@ -20,39 +20,39 @@ SortPackage(S,A) : Exports == Implementation where
with (finiteAggregate; shallowlyMutable)
Exports == with
- bubbleSort_!: (A,(S,S) -> Boolean) -> A
+ bubbleSort!: (A,(S,S) -> Boolean) -> A
++ bubbleSort!(a,f) \undocumented
- insertionSort_!: (A, (S,S) -> Boolean) -> A
+ insertionSort!: (A, (S,S) -> Boolean) -> A
++ insertionSort!(a,f) \undocumented
if S has OrderedSet then
- bubbleSort_!: A -> A
+ bubbleSort!: A -> A
++ bubbleSort!(a) \undocumented
- insertionSort_!: A -> A
+ insertionSort!: A -> A
++ insertionSort! \undocumented
Implementation == add
- bubbleSort_!(m,f) ==
+ bubbleSort!(m,f) ==
n := #m
for i in 1..(n-1) repeat
for j in n..(i+1) by -1 repeat
- if f(m.j,m.(j-1)) then swap_!(m,j,j-1)
+ if f(m.j,m.(j-1)) then swap!(m,j,j-1)
m
- insertionSort_!(m,f) ==
+ insertionSort!(m,f) ==
for i in 2..#m repeat
j := i
while j > 1 and f(m.j,m.(j-1)) repeat
- swap_!(m,j,j-1)
+ swap!(m,j,j-1)
j := (j - 1) pretend PositiveInteger
m
if S has OrderedSet then
- bubbleSort_!(m) == bubbleSort_!(m,_<$S)
- insertionSort_!(m) == insertionSort_!(m,_<$S)
+ bubbleSort!(m) == bubbleSort!(m,_<$S)
+ insertionSort!(m) == insertionSort!(m,_<$S)
if A has UnaryRecursiveAggregate(S) then
- bubbleSort_!(m,fn) ==
+ bubbleSort!(m,fn) ==
empty? m => m
l := m
while not empty? (r := l.rest) repeat
- r := bubbleSort_!(r,fn)
+ r := bubbleSort!(r,fn)
x := l.first
if fn(r.first,x) then
l.first := r.first