source: git/Tst/Manual/Definition_of_a_user_defined_type.tst @ ef52d6

spielwiese
Last change on this file since ef52d6 was 894057, checked in by Oleksandr Motsak <motsak@…>, 13 years ago
ADD: Tests from online manual (res+stat on mamawutz): short ones Tst/Manual/s.lst
  • Property mode set to 100644
File size: 888 bytes
Line 
1LIB "tst.lib"; tst_init();
2  newstruct("nt","int a,poly b,string c");
3  nt A;
4  nt B;
5  A.a=3;
6  A.c=string(A.a);
7  B=A;
8  newstruct("t2","nt","string c");
9  t2 C; C.c="t2-c";
10  A=C;
11  typeof(A);
12  A;
13  // a motivating example ------------------------------------------
14  newstruct("IDEAL","ideal I,proc prettyprint");
15  newstruct("HOMOGENEOUS_IDEAL","IDEAL","intvec weights,proc prettyprint");
16  proc IDEAL_pretty_print(IDEAL I)
17  {
18    "ideal generated by";
19    I.I;
20  }
21  proc H_IDEAL_pretty_print(HOMOGENEOUS_IDEAL I)
22  {
23    "homogeneous ideal generated by";
24    I.I;
25    "with weights";
26    I.weights;
27  }
28  proc p_print(IDEAL I) { I.prettyprint(I); }
29  ring r;
30  IDEAL I;
31  I.I=ideal(x+y2,z);
32  I.prettyprint=IDEAL_pretty_print;
33  HOMOGENEOUS_IDEAL H;
34  H.I=ideal(x,y,z);
35  H.prettyprint=H_IDEAL_pretty_print;
36  H.weights=intvec(1,1,1);
37  p_print(I);
38  p_print(H);
39tst_status(1);$
Note: See TracBrowser for help on using the repository browser.