summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ansys.com>2014-06-25 16:55:43 +0200
committerAlex Auvolat <alex.auvolat@ansys.com>2014-06-25 16:55:43 +0200
commite16f965b88efa1ba7872ced9fed627361c5c2c9e (patch)
tree2beafe42b393b2d02ee94cb393ff736b4db33935 /libs
parent255ec4a98d329d021dbc86ca81a59d562efaa8d1 (diff)
downloadscade-analyzer-e16f965b88efa1ba7872ced9fed627361c5c2c9e.tar.gz
scade-analyzer-e16f965b88efa1ba7872ced9fed627361c5c2c9e.zip
Begin implementation of EDD ; SCA implemented.
Diffstat (limited to 'libs')
-rw-r--r--libs/util.ml35
1 files changed, 22 insertions, 13 deletions
diff --git a/libs/util.ml b/libs/util.ml
index 01b0c5c..443fb1e 100644
--- a/libs/util.ml
+++ b/libs/util.ml
@@ -1,3 +1,21 @@
+(* Small things *)
+
+let ord_couple (a, b) = if a < b then a, b else b, a
+
+(* uniq_sorted : 'a list -> 'a list *)
+let rec uniq_sorted = function
+ | [] -> []
+ | [a] -> [a]
+ | a::b::q when a = b -> uniq_sorted (b::q)
+ | a::r -> a::(uniq_sorted r)
+
+(* list_fold_op : ('a -> 'a -> 'a) -> 'a list -> 'a *)
+let rec list_fold_op op = function
+ | [] -> invalid_arg "list_fold_opt on empty list"
+ | [a] -> a
+ | x::q -> op x (list_fold_op op q)
+
+
(* Either type *)
type ('a, 'b) either =
@@ -47,24 +65,15 @@ let rec fix equal f s =
let (@@) f x = f x
-let print_list x l =
- Format.printf "%s: " x;
+let print_list f sep fmt l =
let rec aux = function
| [] -> ()
- | [a] -> Format.printf "%s" a
- | p::q -> Format.printf "%s, " p; aux q
+ | [a] -> f fmt a
+ | a::b -> f fmt a; Format.fprintf fmt "%s@," sep; aux b
in
- Format.printf "["; aux l; Format.printf "]@."
+ aux l
let uid =
let c = ref 0 in
fun () -> c := !c + 1; string_of_int !c
-(* On lists *)
-
-(* list_fold_op : ('a -> 'a -> 'a) -> 'a list -> 'a *)
-let rec list_fold_op op = function
- | [] -> invalid_arg "list_fold_opt on empty list"
- | [a] -> a
- | x::q -> op x (list_fold_op op q)
-