From 3f25710a891dfcd17f597c16dfedf5499bc1bbd6 Mon Sep 17 00:00:00 2001 From: pacien Date: Fri, 20 Apr 2018 23:32:38 +0200 Subject: Modularize everything --- reg.ml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 reg.ml (limited to 'reg.ml') diff --git a/reg.ml b/reg.ml new file mode 100644 index 0000000..b27a868 --- /dev/null +++ b/reg.ml @@ -0,0 +1,16 @@ +(* + * UPEM / L3 / Functional programming / Project: URM + * Pacien TRAN-GIRARD, Adam NAILI + *) + +open Common + +let reg_idx (Reg(idx, _)) = idx +let reg_val (Reg(_, value)) = value +let reg_compar reg1 reg2 = (reg_val reg1) - (reg_val reg2) + +let regs_get reglist idx = + List.find (fun (Reg(x,v)) -> x = idx) reglist |> reg_val + +let regs_set reglist index value = + Reg(index, value) :: List.filter (fun (Reg(x, v)) -> x != index) reglist -- cgit v1.2.3