let grp_union = union
let prod g1 g2 =
- let aux a = set_iter (fun h -> [union a h]) g2 in
- set_iter aux g1
+ match g1, g2 with
+ | [], [] -> []
+ | _, [] -> g1
+ | [], _ -> g2
+ | _, _ ->
+ let aux a = set_iter (fun h -> [union a h]) g2 in
+ set_iter aux g1
let rec d_union s1 s2 =
match s1, s2 with
| (r1, _) :: _, (r2, _) :: t2 when r1 > r2 -> diff s1 t2
| _ :: t1, _ :: t2 -> diff t1 t2
-(* concatenation ************************************************************)
-
-let append v1 v2 = v1 @ v2
-
(* peeking ******************************************************************)
let peek = function
| [] -> Empty
| [s, gl] -> Single (s, gl)
| (s, gl) :: _ -> Many (s, gl)
+
+(* optimization *************************************************************)
+
+let optimize = List.rev