axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] BINGO, Curiosities with Axiom mathematical structures


From: Martin Rubey
Subject: [Axiom-developer] BINGO, Curiosities with Axiom mathematical structures
Date: 09 Mar 2006 17:08:29 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

I am satisfied now:
-------------------------------------------------------------------------------
#include "axiom"

MyMonoid(T: Type, m: (T, T) -> T): Category == with {
   square: T-> T;
   default {square(t: T): T == m(t, t)}
}

MyWord: with { 
   coerce: String -> %;
   c:(%, %) -> %
}
   == add {
   Rep == String;
   import from String;
   coerce(a: String): % == per(a);
   c(a: %, b: %):%  == coerce(concat(rep(a), rep(b))$String) }

import from MyWord;
extend MyWord: MyMonoid(MyWord, c) == add;
-------------------------------------------------------------------------------

The only slight inconvenience is that we need to have the domain itself as
parameter of the category, too. But I think that's ok, given that there is no
need to change the compiler in any way. I'll post this on SandboxMonoid as
well.

-------------------------------------------------------------------------------

                        AXIOM Computer Algebra System 
                     Version: Axiom 3.9 (September 2005)
               Timestamp: Monday October 31, 2005 at 16:30:26 
-----------------------------------------------------------------------------
   Issue )copyright to view copyright notices.
   Issue )summary for a summary of useful system commands.
   Issue )quit to leave AXIOM and return to shell.
-----------------------------------------------------------------------------
 
   Re-reading compress.daase   Re-reading interp.daase
   Re-reading operation.daase
   Re-reading category.daase
   Re-reading browse.daase
(1) -> 
(1) -> )co test.as

(1) -> )sh MyMonoid
 MyMonoid(T: Type,m: ((T,T) -> T))  is a category constructor
 Abbreviation for MyMonoid is MYMONOI 
 This constructor is exposed in this frame.
 Issue )edit test.as to see algebra source code for MYMONOI 

------------------------------- Operations --------------------------------
 square : T -> T                      

(1) -> )sh MyWord
 MyWord  is a domain constructor
 Abbreviation for MyWord is MYWORD 
 This constructor is exposed in this frame.
 Issue )edit test.as to see algebra source code for MYWORD 

------------------------------- Operations --------------------------------
 c : (%,%) -> %                        coerce : String -> %
 square : MyWord -> MyWord            

(1) -> a := "Bingo"::MyWord

 LISP output:
Bingo
                                                                 Type: MyWord
(2) -> square a

 LISP output:
BingoBingo
                                                                 Type: MyWord

(3) -> MyWord has MyMonoid(MyWord, c)

   (3)  true





reply via email to

[Prev in Thread] Current Thread [Next in Thread]