This seems to work if the category is defined in the same source file (i.e. same section in MathAction). The code is based on the Spad version SandBox Category of Graphs in Spad aldor #pile
#include "axiom.as"
--
-- First we define the general category of graphs.
--
GraphCategory(nodes:Type, edges:Type): Category == with
source:edges->nodes
target:edges->nodes
--
-- Now we define finite graphs as follows:
--
edges ==> Record(source:nodes,target:nodes)
FiniteGraph(nodes: BasicType):GraphCategory(nodes,edges)
with
new: %
addNode: (%,List nodes) -> List nodes
addNode: (%,nodes) -> List nodes
addEdge: (%,nodes,nodes) -> edges
edgeList: (%) -> List edges
nodeList: (%) -> List nodes
aldor Compiling FriCAS source code from file
/var/zope2/var/LatexWiki/1676669208528368195-25px001.as using
AXIOM-XL compiler and options
-O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete -DAxiom -Y $AXIOM/algebra
Use the system command )set compiler args to change these
options.
#1 (Warning) Deprecated message prefix: use `ALDOR_' instead of `_AXL'
Compiling Lisp source code from file
./1676669208528368195-25px001.lsp
Issuing )library command for 1676669208528368195-25px001
Reading /var/zope2/var/LatexWiki/1676669208528368195-25px001.asy
FiniteGraph is now explicitly exposed in frame initial
FiniteGraph will be automatically loaded when needed from
/var/zope2/var/LatexWiki/1676669208528368195-25px001
GraphCategory is now explicitly exposed in frame initial
GraphCategory will be automatically loaded when needed from
/var/zope2/var/LatexWiki/1676669208528368195-25px001axiom )sh FiniteGraph Example 1: create a simple finite graph: axiom g:FiniteGraph(INT) Type: Void
axiom g:=new() Type: FiniteGraph? Integer
axiom addNode(g,1)
Type: List Integer
axiom addNode(g,2)
Type: List Integer
axiom e:=addEdge(g,1,2)
Type: Record(source: Integer,target: Integer)
axiom source(e)$FiniteGraph(INT)
Type: Integer
axiom edgeList(g)
Type: List Record(source: Integer,target: Integer)
axiom nodeList(g)
Type: List Integer
|