axiom-developer
[Top][All Lists]

## [Axiom-developer] [FunctionalMapping]

 From: Bill Page Subject: [Axiom-developer] [FunctionalMapping] Date: Fri, 04 Mar 2005 14:54:49 -0600

```Changes http://page.axiom-developer.org/zope/mathaction/FunctionalMapping/diff
--

This simple package defines an function g which operates on some
function with domain from set and co-domain from Ring and returns
the "square" of that function.

??changed:
-Test1(A:SetCategory):_
-  MPcat == MPdef where
-    B   ==>  Integer
-
-    MPcat ==  with
-        g:(A->B) -> (A ->B)
-
-        MappingPackageInternalHacks3(A, B, B)
-
-        fab:  A -> B
-        sq: B -> B
-
-        sq(x)== (x*x)\$B
-        g(fab) == comp(sq,fab,#1)
Test1(A:SetCategory,B:Ring):_
with  g:(A->B) -> (A ->B) == add
MappingPackage3(A, B, B)
-- which provides the operator * for functional composition
sq(x:B):B == (x*x)\$B
-- then all we need is multiplication from some Ring
g(f:A->B) == sq*f

The call to 'MapplingPackage3' to construct a functional composition
of the right signature seems quite novel to me. I learned this from

Here we apply g to a function over the Ring Integer

??changed:
-p(x:INT):INT == x-1
-p 4
pINT(x:INT):INT == x-1
qINT := g pINT
qINT 5

??changed:
-
This own is over the Ring Float

??changed:
-q := g p
-q 4
pFLOAT(x:FLOAT):FLOAT == x-1
qFLOAT := g pFLOAT
qFLOAT(5.1)

--