**On Date: Jun 26, 2007 8:19 AM Ralf Hemmecke wrote:(( Suppose you want a constructor like: M(T: Tuple Cat): MCat(T) == add {...} for some given category Cat (For simplicity, lets say: define Cat: Category == with {=:(%,%)->Boolean} The question now is how do I define MCat? and the corresponding add {...} in such a way that I am able to generate an element of M in a simple form. Basically, I want to say: import from Integer, String, Boolean; import from M(Integer, String); import from M(String, String, Boolean); a := m(4,"a"); b := m("x", "y", true); Do you have an idea how to define the function m generically? Also I would probably like to have: s: String := b.2; i: Integer := a.1; q: Boolean := b.3; Try to define this apply function. Important, I want to have as much type safety as possible, i.e. If I would have written: c := m(1, "x", false); the compiler should already shout that the type of the first argument doesn't fit. Good luck. Bill Page wrote: Here is a first attempt. It sort of works, but there are problems. fricas (1) -> <aldor> #pile #include "axiom.as" -- M(T: Tuple Type): with m: T -> % get: % -> T == add m(x:T):% == (x) pretend % get(x:%):T == x pretend T</aldor> fricas Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/mm.as using Aldor compiler and options -O -Fasy -Fao -Flsp -lfricas -Mno-ALDOR_W_WillObsolete -DFriCAS -Y $FRICAS/algebra -I $FRICAS/algebra Use the system command )set compiler args to change these options. "/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/mm.as", fricas )show M Unfortunately the Axiom interpreter does not understand fricas a := m(4, But this can be written in Aldor aldor #pile #include "axiom.as" #library mm "mm.ao" import from mm inline from mm -- main():Record(i:String, aldor Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/1927112369448499588-25px004.as using Aldor compiler and options -O -Fasy -Fao -Flsp -lfricas -Mno-ALDOR_W_WillObsolete -DFriCAS -Y $FRICAS/algebra -I $FRICAS/algebra Use the system command )set compiler args to change these options. "/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/1927112369448499588-25px004.as", fricas main() Note: values of j and k are wrong! |