-- add "test" to DD_FILES in Makefile.files to link this with M2
use common;
use util;

export iarray := tarray(int);
export parray := tarray(poly);
export poly := iarray or parray or null;

export intcoeff := {+ c : int, xx:void};
export polycoeff := intcoeff or iarray or parray or null;

export ring := {+ charac:int, extensions:parray };
export Poly := {+ r:ring, level:int, f:poly};

export addpoly(r:ring,level:int,f:poly,g:poly):poly := (
     f
     );
export subpoly(r:ring,level:int,f:poly,g:poly):poly := (
     f
     );

export tostring(level:int, f:poly):string := (
     when f
     is f0:iarray do (
          a := new array(string) len length(f0) do
            foreach y in f0 do
              provide if y == 0 then "0 " else tostring(y) + " ";
          "[" + concatenate(a) + "]"
          )
     is fn:parray do "not done yet"
     is null do "0"
     );

export (f:Poly) + (g:Poly) : Poly := Poly(f.r,f.level,addpoly(f.r,f.level,f.f,g.f));
export (f:Poly) - (g:Poly) : Poly := Poly(f.r,f.level,subpoly(f.r,f.level,f.f,g.f));

export testPolys(e:Expr):Expr := (
     f := poly(iarray(1,2,4));
     g := poly(iarray(1,0,0,1,2));
     R := ring(11, parray());
     h := addpoly(R,0,f,g);
     x := toInteger(2);
     stdIO << tostring(x ^ 500) << endl;
     toExpr(tostring(0,g))
     );
setupfun("testPolys", testPolys);



-- this next line is needed for a stand-alone program, but not when linking with M2
-- header "int main () { return 0; }";


-- Local Variables:
-- mode: M2
-- compile-command: "echo \"make: Entering directory \\`$M2BUILDDIR/Macaulay2/e'\" && make -C $M2BUILDDIR/Macaulay2/e test-tmp.cc test-exports.h test.o "
-- End:
