aboutsummaryrefslogtreecommitdiff
path: root/src/algebra/tree.spad.pamphlet
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2013-05-18 01:31:50 +0000
committerdos-reis <gdr@axiomatics.org>2013-05-18 01:31:50 +0000
commit681f30e8a2a60c506f1ad8c45fe182baf2ff51bf (patch)
tree3d2a3995c5bdcb64314da504837faa1aa604cdd1 /src/algebra/tree.spad.pamphlet
parentec665f7a23f25ff744435152d93480b4f31d3a08 (diff)
downloadopen-axiom-681f30e8a2a60c506f1ad8c45fe182baf2ff51bf.tar.gz
* algebra/tree.spad.pamphlet(BinaryTreeCategory): Extend
ShallowlyMutableAggregate S. (BinarySearchTree): Remove redundant shallowlyMutable attribute. (BalancedBinaryTree): Likewise.
Diffstat (limited to 'src/algebra/tree.spad.pamphlet')
-rw-r--r--src/algebra/tree.spad.pamphlet20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/algebra/tree.spad.pamphlet b/src/algebra/tree.spad.pamphlet
index 1352bd35..985f6dc5 100644
--- a/src/algebra/tree.spad.pamphlet
+++ b/src/algebra/tree.spad.pamphlet
@@ -328,9 +328,7 @@ Tree(S: SetCategory): T==C where
++ Description: \spadtype{BinaryTreeCategory(S)} is the category of
++ binary trees: a tree which is either empty or else is a \spadfun{node} consisting
++ of a value and a \spadfun{left} and \spadfun{right}, both binary trees.
-BinaryTreeCategory(S: SetCategory): Category == Join(BinaryRecursiveAggregate S,FiniteAggregate S) with
- shallowlyMutable
- ++ Binary trees have updateable components
+BinaryTreeCategory(S: SetCategory): Category == Join(BinaryRecursiveAggregate S,FiniteAggregate S,ShallowlyMutableAggregate S) with
node: (%,S,%) -> %
++ node(left,v,right) creates a binary tree with value \spad{v}, a binary
++ tree \spad{left}, and a binary tree \spad{right}.
@@ -340,13 +338,12 @@ BinaryTreeCategory(S: SetCategory): Category == Join(BinaryRecursiveAggregate S,
copy t ==
empty? t => empty()
node(copy left t, value t, copy right t)
- if % has shallowlyMutable then
- map!(f,t) ==
- empty? t => t
- t.value := f(t.value)
- map!(f,left t)
- map!(f,right t)
- t
+ map!(f,t) ==
+ empty? t => t
+ t.value := f(t.value)
+ map!(f,left t)
+ map!(f,right t)
+ t
treeCount : (%, NonNegativeInteger) -> NonNegativeInteger
#t == treeCount(t,0)
treeCount(t,k) ==
@@ -414,7 +411,6 @@ BinaryTree(S: SetCategory): Exports == Implementation where
++ Elements are ordered across the tree.
BinarySearchTree(S: OrderedSet): Exports == Implementation where
Exports == BinaryTreeCategory(S) with
- shallowlyMutable
binarySearchTree: List S -> %
++ binarySearchTree(l) \undocumented
insert!: (S,%) -> %
@@ -460,7 +456,6 @@ BinarySearchTree(S: OrderedSet): Exports == Implementation where
++ and a \spadfun{left} which are both \spadtype{BinaryTree(S)}
BinaryTournament(S: OrderedSet): Exports == Implementation where
Exports == BinaryTreeCategory(S) with
- shallowlyMutable
binaryTournament: List S -> %
++ binaryTournament(ls) creates a binary tournament with the
++ elements of ls as values at the nodes.
@@ -494,7 +489,6 @@ BinaryTournament(S: OrderedSet): Exports == Implementation where
++ by at most leaf node.
BalancedBinaryTree(S: SetCategory): Exports == Implementation where
Exports == BinaryTreeCategory(S) with
- shallowlyMutable
-- BUG: applies wrong fnct for balancedBinaryTree(0,[1,2,3,4])
-- balancedBinaryTree: (S, List S) -> %
-- ++ balancedBinaryTree(s, ls) creates a balanced binary tree with