/usr/share/axiom-20170501/src/algebra/PATTERN2.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 | )abbrev package PATTERN2 PatternFunctions2
++ Author: Manuel Bronstein
++ Date Created: 28 Nov 1989
++ Date Last Updated: 12 Jan 1990
++ Description:
++ Lifts maps to patterns
PatternFunctions2(R,S) : SIG == CODE where
R : SetCategory
S : SetCategory
SIG ==> with
map : (R -> S, Pattern R) -> Pattern S
++ map(f, p) applies f to all the leaves of p and
++ returns the result as a pattern over S.
CODE ==> add
map(f, p) ==
(r := (retractIfCan p)@Union(R, "failed")) case R =>
f(r::R)::Pattern(S)
(u := isOp p) case Record(op:BasicOperator, arg:List Pattern R) =>
ur := u::Record(op:BasicOperator, arg:List Pattern R)
(ur.op) [map(f, x) for x in ur.arg]
(v := isQuotient p) case Record(num:Pattern R, den:Pattern R) =>
vr := v::Record(num:Pattern R, den:Pattern R)
map(f, vr.num) / map(f, vr.den)
(l := isPlus p) case List(Pattern R) =>
reduce("+", [map(f, x) for x in l::List(Pattern R)])
(l := isTimes p) case List(Pattern R) =>
reduce("*", [map(f, x) for x in l::List(Pattern R)])
(x := isPower p) case
Record(val:Pattern R, exponent: Pattern R) =>
xr := x::Record(val:Pattern R, exponent: Pattern R)
map(f, xr.val) ** map(f, xr.exponent)
(w := isExpt p) case
Record(val:Pattern R, exponent: NonNegativeInteger) =>
wr := w::Record(val:Pattern R, exponent: NonNegativeInteger)
map(f, wr.val) ** wr.exponent
sy := retract(p)@Symbol
setPredicates(sy::Pattern(S), copy predicates p)
|