-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
78 lines (53 loc) · 1.92 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System;
using System.Collections.Generic;
using System.Text;
namespace smn
{
class MainClass
{
public static void Main (string[] args)
{
int p = 1;
int q = 0;
int r = 7;
int s = 7;
//Console.WriteLine ("p={0},q={1},r={2},s={3}", p, q, r, s);
Console.WriteLine ("Discriminator with 4 args:");
var disc = PartRecFactory.GetFunction (3, 0);
for (int i=-2; i<=2; i++) {
var parameters = new System.Collections.Generic.List<int> () { p, q, r, s+i };
int res = disc.Execute (parameters);
Console.WriteLine ("{{{0}}}{1} = {2}", disc.ToString (), IntListToString (parameters), res);
}
Console.WriteLine ("Discrimator with 3 args:");
var disc2 = PartRecFactory.ApplySN1 (disc,1, 4);
for (int i=-2; i<=2; i++) {
var parameters = new System.Collections.Generic.List<int> () { q, r, s+i};
int res = disc2.Execute (parameters);
Console.WriteLine ("{{{0}}}{1} = {2}", disc2.ToString (), IntListToString (parameters), res);
}
Console.WriteLine ("Discrimator with 2 args:");
var disc3 = PartRecFactory.ApplySN1 (disc2,0, 3);
for (int i=-2; i<=2; i++) {
var parameters = new System.Collections.Generic.List<int> () { r, s+i};
int res = disc3.Execute (parameters);
Console.WriteLine ("{{{0}}}{1} = {2}", disc3.ToString (), IntListToString (parameters), res);
}
Console.WriteLine ("Discrimator with 1 args:");
var disc4 = PartRecFactory.ApplySN1 (disc3,7, 2);
for (int i=-2; i<=2; i++) {
var parameters = new System.Collections.Generic.List<int> () { s+i};
int res = disc4.Execute (parameters);
Console.WriteLine ("{{{0}}}{1} = {2}", disc4.ToString (), IntListToString (parameters), res);
}
}
private static string IntListToString(List<int> list)
{
StringBuilder bldr = new StringBuilder ();
bldr.Append ("(");
bldr.Append (String.Join (",", list.ToArray ()));
bldr.Append (")");
return bldr.ToString ();
}
}
}