/usr/share/axiom-20170501/src/algebra/MAPHACK1.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 | )abbrev package MAPHACK1 MappingPackageInternalHacks1
++ Author: S.M.Watt and W.H.Burge
++ Date Created:Jan 87
++ Date Last Updated:Feb 92
++ Description:
++ Various Currying operations.
MappingPackageInternalHacks1(A) : SIG == CODE where
A : SetCategory
NNI ==> NonNegativeInteger
SIG ==> with
iter : ((A -> A), NNI, A) -> A
++\spad{iter(f,n,x)} applies \spad{f n} times to \spad{x}.
recur : ((NNI, A)->A, NNI, A) -> A
++\spad{recur(n,g,x)} is \spad{g(n,g(n-1,..g(1,x)..))}.
CODE ==> add
iter(g,n,x) ==
for i in 1..n repeat x := g x -- g(g(..(x)..))
x
recur(g,n,x) ==
for i in 1..n repeat x := g(i,x) -- g(n,g(n-1,..g(1,x)..))
x
|