oldk1331
2018-11-19 10:38:27 UTC
Cleanup 'nodes' and 'leaves':
move default implementation of 'nodes' from Tree to RCAGG
remove duplicated implementation of 'leaves' in Tree
add default implementation of 'leaves' to URAGG
diff --git a/src/algebra/aggcat.spad b/src/algebra/aggcat.spad
index c3b69f3c..caa83202 100644
--- a/src/algebra/aggcat.spad
+++ b/src/algebra/aggcat.spad
@@ -1104,6 +1104,10 @@
empty? x => false
empty? children x
+ nodes x ==
+ empty? x => empty()
+ concat(x, concat [nodes y for y in children x])
+
leaves x ==
empty? x => empty()$List(S)
leaf? x => [value x]
@@ -1425,6 +1429,10 @@
empty? rest x => empty()
[rest x]
+ leaves x ==
+ empty? x => empty()
+ tail x
+
leaf? x ==
empty? x => false
empty? rest x
diff --git a/src/algebra/tree.spad b/src/algebra/tree.spad
index c58aae21..8eaeb175 100644
--- a/src/algebra/tree.spad
+++ b/src/algebra/tree.spad
@@ -96,17 +96,8 @@
leaf? t ==
t case empty => false
empty? children t
- leaves t ==
- t case empty => empty()
- leaf? t => [value t]
- "append"/[leaves c for c in children t]
less? (t, n) == # t < n
more?(t, n) == # t > n
- nodes t == ---buggy
- t case empty => empty()
- nl := [nodes c for c in children t]
- nl = empty() => [t]
- cons(t,"append"/nl)
size? (t, n) == # t = n
any?(fn, t) == ---bug fixed
t case empty => false
move default implementation of 'nodes' from Tree to RCAGG
remove duplicated implementation of 'leaves' in Tree
add default implementation of 'leaves' to URAGG
diff --git a/src/algebra/aggcat.spad b/src/algebra/aggcat.spad
index c3b69f3c..caa83202 100644
--- a/src/algebra/aggcat.spad
+++ b/src/algebra/aggcat.spad
@@ -1104,6 +1104,10 @@
empty? x => false
empty? children x
+ nodes x ==
+ empty? x => empty()
+ concat(x, concat [nodes y for y in children x])
+
leaves x ==
empty? x => empty()$List(S)
leaf? x => [value x]
@@ -1425,6 +1429,10 @@
empty? rest x => empty()
[rest x]
+ leaves x ==
+ empty? x => empty()
+ tail x
+
leaf? x ==
empty? x => false
empty? rest x
diff --git a/src/algebra/tree.spad b/src/algebra/tree.spad
index c58aae21..8eaeb175 100644
--- a/src/algebra/tree.spad
+++ b/src/algebra/tree.spad
@@ -96,17 +96,8 @@
leaf? t ==
t case empty => false
empty? children t
- leaves t ==
- t case empty => empty()
- leaf? t => [value t]
- "append"/[leaves c for c in children t]
less? (t, n) == # t < n
more?(t, n) == # t > n
- nodes t == ---buggy
- t case empty => empty()
- nl := [nodes c for c in children t]
- nl = empty() => [t]
- cons(t,"append"/nl)
size? (t, n) == # t = n
any?(fn, t) == ---bug fixed
t case empty => false
--
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel+***@googlegroups.com.
To post to this group, send email to fricas-***@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.