Skip to content
Newer
Older
100644 29 lines (25 sloc) 627 Bytes
ed624f5 @esilkensen Initial commit
authored Sep 5, 2012
1 module Sets {
2 types {
3 Type ::= T:Type "Set" == (Setof T);
4 Type ::= T:Type "Seq" == (Listof T);
5 }
6
7 // macros
8 forall T.
9 T Set ::= "{" x:T "}" => (set x);
10 forall T.
11 T Set ::= "{" x:T xs:(T Seq) "}" => (list->set (cons x xs));
12
13 forall T.
14 T Seq ::= "," x:T => (list x);
15 forall T.
16 T Seq ::= "," x:T xs:(T Seq) => (cons x xs);
17
18 // functions
19 forall T.
20 T Set ::= s1:(T Set) "|" s2:(T Set) [left 1] =
21 (set-union s1 s2);
22 forall T.
23 T Set ::= s1 : (T Set) "&" s2:(T Set) [left 2] =
24 (set-intersect s1 s2);
25 forall T.
26 Integer ::= "|" s:(T Set) "|" =
27 (set-count s);
28 }
Something went wrong with that request. Please try again.