From 38cf58ac5e1adb38a1b99ea7cdda19ef7b5e12bf Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 24 May 2021 22:13:19 +0200 Subject: Refactor --- script.it/outline/dune | 9 +++++++++ script.it/outline/outline.ml | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 script.it/outline/dune create mode 100755 script.it/outline/outline.ml (limited to 'script.it/outline') diff --git a/script.it/outline/dune b/script.it/outline/dune new file mode 100755 index 0000000..db080a3 --- /dev/null +++ b/script.it/outline/dune @@ -0,0 +1,9 @@ +(library + (name outline) + (libraries + path) + (modules outline) + (preprocess (pps ppx_hash js_of_ocaml-ppx)) + ) + + diff --git a/script.it/outline/outline.ml b/script.it/outline/outline.ml new file mode 100755 index 0000000..1df7588 --- /dev/null +++ b/script.it/outline/outline.ml @@ -0,0 +1,21 @@ +open StdLabels + +let internal_path_id = ref 0 + +type t = + { id : int + ; path: Path.Fixed.t + ; back: Path.Fixed.t + } + +let get_id () = + let id = !internal_path_id in + incr internal_path_id; + id + +let find + : t list -> int -> t option + = fun ts id -> + List.find_opt + ts + ~f:(fun p -> p.id = id) -- cgit v1.2.3