login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

In a domain and in categories referenced in a domain the notation % represents "this domain" (or self in some programming languages). So we commonly write for example:

  with
    f: (%,%) -> %

to indicate a function f which takes a pair of values in this domain and returns a value in this same domain - whatever domain we happen to be talking about in this context.

But what if we are interested in the domain as a functor? Suppose I was writing an "endofunctor" domain constructor like Set and I wanted to treat constructions like Set Set R, i.e. sets of sets as something special. E.g.

spad
)abbrev domain MYSET MySet
MySet(T:SetCategory): SetAggregate(T) with
     finiteAggregate
     join: MySet MySet T -> MySet T
   == add
     Rep == List T
     --rep(x:%):Rep == x pretend Rep
     --per(x:Rep):% == x pretend %
Rep2 := List List T rep2(x:MySet MySet T):Rep2 == x pretend Rep2 per2(x:Rep2):MySet MySet T == x pretend MySet MySet T
coerce(x:%):OutputForm == brace [i::OutputForm for i in rep x] x = y == rep(x) = rep(y) construct(x) == per removeDuplicates(x)$Rep parts(x:%):List T == rep x join x == construct concat rep2 x
spad
   Compiling OpenAxiom source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7834450198179479618-25px001.spad
      using Spad compiler.
   MYSET abbreviates domain MySet 
------------------------------------------------------------------------
   initializing NRLIB MYSET for MySet 
   compiling into NRLIB MYSET 
   Adding $ modemaps
   Adding T$ modemaps
   Adding Rep modemaps
   Adding Rep2 modemaps
   Adding MySet MySet T$ modemaps
   compiling local rep2 : MySet MySet T -> Rep2
   Adding List T$ modemaps
   Adding List List T$ modemaps
      MYSET;rep2 is replaced by x 
Time: 0.08 SEC.
Adding MySet MySet T$ modemaps compiling local per2 : Rep2 -> MySet MySet T MYSET;per2 is replaced by x Time: 0.02 SEC.
Adding OutputForm modemaps compiling exported coerce : % -> OutputForm Adding List OutputForm modemaps Adding List T$ modemaps Time: 0.02 SEC.
Adding Boolean modemaps compiling exported = : (%,%) -> Boolean Time: 0.01 SEC.
Adding List T$ modemaps compiling exported construct : List T -> % Time: 0.03 SEC.
Adding List T$ modemaps compiling exported parts : % -> List T MYSET;parts;$L;6 is replaced by x Time: 0 SEC.
Adding MySet T$ modemaps compiling exported join : MySet MySet T -> MySet T Adding List T$ modemaps Adding List Rep modemaps Adding List List T$ modemaps Time: 0.05 SEC.
Adding T$ modemaps Note: Domain T$ already in scope augmenting T$: Evalable T$ augmenting $: shallowlyMutable Adding T$ modemaps Note: Domain T$ already in scope augmenting T$: ConvertibleTo InputForm Predicate: (|has| $ (ATTRIBUTE |finiteAggregate|)) replaced by: T Predicate: (|has| $ (ATTRIBUTE |shallowlyMutable|)) replaced by: NIL Predicate: (|has| $ (ATTRIBUTE |finiteAggregate|)) replaced by: T (time taken in buildFunctor: 0)
;;; *** |MySet| REDEFINED
;;; *** |MySet| REDEFINED Time: 0.01 SEC.
Cumulative Statistics for Constructor MySet Time: 0.22 seconds
finalizing NRLIB MYSET Processing MySet for Browser database: --->-->MySet((join ((MySet T$) (MySet (MySet T$))))): Not documented!!!! --->-->MySet(constructor): Not documented!!!! --->-->MySet: Missing Description
; compiling file "/var/aw/var/LatexWiki/MYSET.NRLIB/code.lsp" (written 31 JUL 2013 03:24:10 PM): ; compiling (/VERSIONCHECK 2) ; compiling (PUT (QUOTE |MYSET;rep2|) ...) ; compiling (DEFUN |MYSET;rep2| ...) ; compiling (PUT (QUOTE |MYSET;per2|) ...) ; compiling (DEFUN |MYSET;per2| ...) ; compiling (DEFUN |MYSET;coerce;$Of;3| ...) ; compiling (DEFUN |MYSET;=;2$B;4| ...) ; compiling (DEFUN |MYSET;construct;L$;5| ...) ; compiling (PUT (QUOTE |MYSET;parts;$L;6|) ...) ; compiling (DEFUN |MYSET;parts;$L;6| ...) ; compiling (DEFUN |MYSET;join;Ms$;7| ...) ; compiling (DEFUN |MySet| ...) ; compiling (DEFUN |MySet;| ...) ; compiling (MAKEPROP (QUOTE |MySet|) ...)
; /var/aw/var/LatexWiki/MYSET.NRLIB/code.fasl written ; compilation finished in 0:00:00.114 ------------------------------------------------------------------------ MySet is now explicitly exposed in frame initial MySet will be automatically loaded when needed from /var/aw/var/LatexWiki/MYSET.NRLIB/code.fasl

fricas
m1:MySet(Integer) := construct([1,2,3])$MySet(Integer)

\label{eq1}\left\{ 1, \: 2, \: 3 \right\}(1)
Type: MySet? Integer
fricas
m2:MySet(Integer) := construct([4,5,6])$MySet(Integer)

\label{eq2}\left\{ 4, \: 5, \: 6 \right\}(2)
Type: MySet? Integer
fricas
ml:=[m1,m2]

\label{eq3}\left[{\left\{ 1, \: 2, \: 3 \right\}}, \:{\left\{ 4, \: 5, \: 6 \right\}}\right](3)
Type: List MySet? Integer
fricas
mm:MySet MySet Integer := construct([m1,m2])$MySet(MySet(Integer))

\label{eq4}\left\{{\left\{ 1, \: 2, \: 3 \right\}}, \:{\left\{ 4, \: 5, \: 6 \right\}}\right\}(4)
Type: MySet? MySet? Integer
fricas
join mm

\label{eq5}\left\{ 1, \: 2, \: 3, \: 4, \: 5, \: 6 \right\}(5)
Type: MySet? Integer




  Subject:   Be Bold !!
  ( 13 subscribers )  
Please rate this page: