Merge remote branch 'master'
[prop.git] / tests / tuple.pcc
blobfc71bd2079d74063fd5e65ab9cfd1934fc903d77
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 //  Testing tuples
4 //
5 ///////////////////////////////////////////////////////////////////////////////
6 #include <iostream.h>
8 const .[int,int]                  a = .(1,2);
9 const .[char,Quark,double] b = .('k',#"Church Rosser",3.0);
11 datatype List<a> = #[] | #[ a ... List<a> ];
13 ostream& operator << (ostream& f, List<.[int,int]> l)
14 {  f << '[';
15    match while (l)
16    {  #[ .(x,y) ... t ]:  
17       { f << '(' << x << ',' << y << ')'; 
18         if (t) f << ", ";
19         l = t;
20       }
21    }
22    f << ']';
23    return f;
26 int main()
28    List<.[int,int]> fib = #[ .(1,1),  .(2,2),  .(3,3),  .(4,5),  .(5,8), 
29                              .(6,13), .(7,21), .(8,34), .(9,55), .(10,89)
30                           ];
31    cout << "Fibonacci numbers = " << fib << '\n';
32    return 0;