Commit 0ed42bf9 authored by Aliaume Lopez's avatar Aliaume Lopez
Browse files

Insertion du code de Dan

parent e8fa06fd
Pipeline #532 skipped
OCAMLCC=ocamlc
OSRC=utils.ml ast.ml dot.ml solver.ml typesystem.ml dags.ml compiler.ml
OSRCL=utils.mli ast.mli dot.mli typesystem.mli
OSRCL=utils.mli ast.mli dot.mli typesystem.mli dags.mli
.PHONY: test clean doc
......@@ -16,6 +16,10 @@ tests: $(OSRC) $(OSRCL) tests.ml
$(OCAMLCC) -g -o tests $(OSRC) tests.ml
./tests
circuits: $(OSRCL) $(ORSC) circuits.ml
$(OCAMLCC) $(OSRCL)
$(OCAMLCC) -g -o circuits $(OSRC) circuits.ml
./circuits
examples: $(OSRC) $(OSRCL) examples.ml
$(OCAMLCC) $(OSRCL)
......
This diff is collapsed.
......@@ -160,10 +160,38 @@ let remove_duplicates l =
|> List.fold_left remdup (None, [])
|> snd;;
(*
* Unsafely get the inside of an option
*)
let of_option = function
| None -> failwith "oups, option none"
| Some x -> x;;
(*
* Convert a list of options into
* a list without the Nones
*)
let list_of_options l =
l |> List.filter (fun x -> not (x = None))
|> List.map of_option;;
(*
* Removes the elements of b
* from the list a
*
* Warning: does not preserve order !
*)
let remove_list a b =
let l1 = List.sort compare a in
let l2 = List.sort compare b in
let rec aux acc rest1 rest2 = match (rest1,rest2) with
| ([],_) -> List.rev acc
| (x,[]) -> List.rev acc @ x
| (x :: q, y :: p) when x = y -> aux acc q rest2
| (x :: q, y :: p) when x > y -> aux acc rest1 p
| (x :: q, y :: p) when x < y -> aux (x :: acc) q rest2
in
aux [] l1 l2;;
(**
* Put the list in the right order
......
......@@ -14,5 +14,7 @@ val imageV : elem:'a -> func:('a * 'b) list -> 'b option
val fiberV : elem:'a -> func:('b * 'a) list -> 'b list
val remove_duplicates : 'a list -> 'a list
val of_option : 'a option -> 'a
val list_of_options : 'a option list -> 'a list
val remove_list : 'a list -> 'a list -> 'a list
val correct_list : ('a * 'b) list -> ('a * 'b) list
val tests : (string * (unit -> unit)) list
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment