/usr/share/axiom-20170501/src/algebra/DSTREE.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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | )abbrev domain DSTREE DesingTree
++ Authors: Gaetan Hache
++ Date Created: jan 1998
++ Date Last Updated: May 2010 by Tim Daly
++ Description:
++ This category is part of the PAFF package
DesingTree(S) : SIG == CODE where
S : SetCategory
SIG ==> DesingTreeCategory(S) with
encode : % -> String
++ encode(t) returns a string indicating the "shape" of the tree
fullOut : % -> OutputForm
++ fullOut(tr) yields a full output of tr (see function fullOutput).
fullOutput : Boolean -> Boolean
++ fullOutput(b) sets a flag such that when true,
++ a coerce to OutputForm yields the full output of
++ tr, otherwise encode(tr) is output (see encode function).
++ The default is false.
fullOutput : () -> Boolean
++ fullOutput returns the value of the flag set by fullOutput(b).
CODE ==> add
Rep ==> Record(value: S, args: List %)
fullOut(t:%): OutputForm ==
empty? children t => (value t) ::OutputForm
prefix((value t)::OutputForm, [fullOut(tr) for tr in children t])
fullOutputFlag:Boolean:=false()
fullOutput(f)== fullOutputFlag:=f
fullOutput == fullOutputFlag
leaves(t)==
empty?(chdr:=children(t)) => list(value(t))
concat([leaves(subt) for subt in chdr])
t1=t2 == value t1 = value t2 and children t1 = children t2
coerce(t:%):OutputForm==
^fullOutput() => encode(t) :: OutputForm
fullOut(t)
tree(s,ls) == ([s,ls]:Rep):%
tree(s:S) == ([s,[]]:Rep):%
tree(ls:List(S))==
empty?(ls) =>
error "Cannot create a tree with an empty list"
f:=first(ls)
empty?(rs:=rest(ls)) =>
tree(f)
tree(f,[tree(rs)])
value t == (t:Rep).value
children t == ((t:Rep).args):List %
setchildren_!(t,ls) == ((t:Rep).args:=ls;t pretend %)
setvalue_!(t,s) == ((t:Rep).value:=s;s)
encode(t)==
empty?(chtr:=children(t)) => empty()$String
concat([concat(["U",encode(arb),"."]) for arb in chtr])
|