/usr/share/axiom-20170501/src/algebra/ANY1.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 | )abbrev package ANY1 AnyFunctions1
++ Description:
++ \spadtype{AnyFunctions1} implements several utility functions for
++ working with \spadtype{Any}. These functions are used to go back
++ and forth between objects of \spadtype{Any} and objects of other
++ types.
AnyFunctions1(S) : SIG == CODE where
S:Type
SIG ==> with
coerce : S -> Any
++ coerce(s) creates an object of \spadtype{Any} from the
++ object \spad{s} of type \spad{S}.
retractIfCan : Any -> Union(S, "failed")
++ retractIfCan(a) tries change \spad{a} into an object
++ of type \spad{S}. If it can, then such an object is
++ returned. Otherwise, "failed" is returned.
retractable? : Any -> Boolean
++ retractable?(a) tests if \spad{a} can be converted
++ into an object of type \spad{S}.
retract : Any -> S
++ retract(a) tries to convert \spad{a} into an object of
++ type \spad{S}. If possible, it returns the object.
++ Error: if no such retraction is possible.
CODE ==> add
import NoneFunctions1(S)
Sexpr:SExpression := devaluate(S)$Lisp
retractable? a == dom(a) = Sexpr
coerce(s:S):Any == any(Sexpr, s::None)
retractIfCan a ==
retractable? a => obj(a) pretend S
"failed"
retract a ==
retractable? a => obj(a) pretend S
error "Cannot retract value."
|