gcc config
[prop.git] / prop-src / listimpl.ph
blob816429a03c5b402bb4423328374ec2a2afe8d226
1 #ifndef list_operations_implementations_h
2 #define list_operations_himplementations_
4 #include "basics.ph"
6 #pragma interface
8 template <class T>
9    int length (List<T> l)
10    {  int len = 0;
11       match while (l)
12       {  #[ _ ... t]: { l = t; len++; } 
13       }
14       return len;
15    }
17 template <class T>
18    List<T> append (List<T> a, List<T> b)
19    {  match (a)
20       {  #[]:        { return b; }
21       |  #[h ... t]: { return #[ h ... append(t, b)]; }
22       }
23    }
25 template <class T>
26    List<T> rev (List<T> a)
27    {  List<T> b = #[];
28       match while (a)
29       {  #[one ... rest]: { b = #[ one ... b ]; a = rest; }
30       } 
31       return b;
32    } 
35 #endif