1 | proc set_defaults(list t) |
---|
2 | { |
---|
3 | attrib(test_proc_1, "default_arg", t); |
---|
4 | attrib(test_proc_2, "default_arg", t); |
---|
5 | attrib(test_proc_3, "default_arg", t); |
---|
6 | } |
---|
7 | |
---|
8 | proc test_all() |
---|
9 | { |
---|
10 | test_proc_1(17); |
---|
11 | test_proc_2(); |
---|
12 | test_proc_3(); |
---|
13 | } |
---|
14 | |
---|
15 | proc test_proc_1 (int i, list #) |
---|
16 | "test 1 for default argument list" |
---|
17 | { |
---|
18 | "proc test_proc_1:"; |
---|
19 | " square of first argument:", i*i; |
---|
20 | " further arguments:"; |
---|
21 | if (size(#)==0) {" none";} |
---|
22 | else { |
---|
23 | for (int k = 1; k <= size(#); k = k + 1) { |
---|
24 | " default argument at index", k, ":",#[k]; |
---|
25 | } |
---|
26 | } |
---|
27 | } |
---|
28 | |
---|
29 | proc test_proc_2 |
---|
30 | //"test 2 for default argument list" |
---|
31 | { |
---|
32 | "proc test_proc_2:"; |
---|
33 | " arguments:"; |
---|
34 | if (size(#)==0) {" none";} |
---|
35 | else { |
---|
36 | for (int k = 1; k <= size(#); k = k + 1) { |
---|
37 | " default argument at index", k, ":",#[k]; |
---|
38 | } |
---|
39 | } |
---|
40 | } |
---|
41 | |
---|
42 | proc test_proc_3 (list #) |
---|
43 | "test 3 for default argument list" |
---|
44 | { |
---|
45 | "proc test_proc_3:"; |
---|
46 | " arguments:"; |
---|
47 | if (size(#)==0) {" none";} |
---|
48 | else { |
---|
49 | for (int k = 1; k <= size(#); k = k + 1) { |
---|
50 | " default argument at index", k, ":",#[k]; |
---|
51 | } |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | ring r = (0), (x, y, z), dp; |
---|
56 | |
---|
57 | list l = 4, 2, "a", 67, x; |
---|
58 | set_defaults(l); |
---|
59 | test_all(); |
---|
60 | |
---|
61 | list l; |
---|
62 | set_defaults(l); |
---|
63 | test_all(); |
---|
64 | |
---|
65 | list l = -y*y+z*x*y+x*x; |
---|
66 | set_defaults(l); |
---|
67 | test_all(); |
---|