From 71ab30c3bb92fe35461814836b3e39c1570ea18d Mon Sep 17 00:00:00 2001 From: Leandro-rdz Date: Mon, 2 Dec 2024 17:40:58 +0100 Subject: [PATCH] feat : add take_min from a list --- src/tools.ml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tools.ml b/src/tools.ml index d8e0d9e..ad9b0e6 100644 --- a/src/tools.ml +++ b/src/tools.ml @@ -24,3 +24,11 @@ let update_graph graph list value = add_arc graph id2 id1 value in aux graph rest value in aux graph list value + + let rec take_min graph l acu = + match l with + |[]->acu + |(id1,id2)::rest -> let arc = find_arc graph id1 id2 in + match arc with + | None-> raise Not_found + | Some x -> if x.lbl < acu then take_min graph rest x.lbl else take_min graph rest acu \ No newline at end of file