/usr/share/axiom-20170501/src/algebra/PENDTREE.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | )abbrev domain PENDTREE PendantTree
++ Author: Mark Botch
++ Description:
++ A PendantTree(S) is either a leaf? and is an S or has
++ a left and a right both PendantTree(S)'s
PendantTree(S) : SIG == CODE where
S : SetCategory
SIG ==> BinaryRecursiveAggregate(S) with
ptree : S->%
++ ptree(s) is a leaf? pendant tree
++
++X t1:=ptree([1,2,3])
ptree : (%, %)->%
++ ptree(x,y) is not documented
++
++X t1:=ptree([1,2,3])
++X ptree(t1,ptree([1,2,3]))
coerce : %->Tree S
++ coerce(x) is not documented
++
++X t1:=ptree([1,2,3])
++X t2:=ptree(t1,ptree([1,2,3]))
++X t2::Tree List PositiveInteger
CODE ==> add
Rep := Tree S
import Tree S
coerce (t:%):Tree S == t pretend Tree S
ptree(n) == tree(n,[])$Rep pretend %
ptree(l,r) == tree(value(r:Rep)$Rep,cons(l,children(r:Rep)$Rep)):%
leaf? t == empty?(children(t)$Rep)
t1=t2 == (t1:Rep) = (t2:Rep)
left b ==
leaf? b => error "ptree:no left"
first(children(b)$Rep)
right b ==
leaf? b => error "ptree:no right"
tree(value(b)$Rep,rest (children(b)$Rep))
value b ==
leaf? b => value(b)$Rep
error "the pendant tree has no value"
coerce(b:%): OutputForm ==
leaf? b => value(b)$Rep :: OutputForm
paren blankSeparate [left b::OutputForm,right b ::OutputForm]
|