diff options
Diffstat (limited to 'reg.ml')
-rw-r--r-- | reg.ml | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -10,11 +10,7 @@ let reg_val (Reg(_, value)) = value | |||
10 | let reg_compar l r = (reg_val l) - (reg_val r) | 10 | let reg_compar l r = (reg_val l) - (reg_val r) |
11 | let reg_string (Reg (index, value)) = "(" ^ (string_of_int index) ^ "," ^ (string_of_int value) ^ ")" | 11 | let reg_string (Reg (index, value)) = "(" ^ (string_of_int index) ^ "," ^ (string_of_int value) ^ ")" |
12 | 12 | ||
13 | let regs_get reglist index = | 13 | let regs_get reglist index = List.find (fun (Reg(idx, _)) -> idx = index) reglist |> reg_val |
14 | List.find (fun (Reg(idx, _)) -> idx = index) reglist |> reg_val | 14 | let regs_set reglist index value = Reg(index, value) :: List.filter (fun (Reg(idx, _)) -> idx != index) reglist |
15 | 15 | let regs_sort = List.sort (fun (Reg(l, _)) (Reg(r, _)) -> compare l r) | |
16 | let regs_set reglist index value = | 16 | let regs_string reglist = regs_sort reglist |> List.map (reg_string) |> String.concat "," |
17 | Reg(index, value) :: List.filter (fun (Reg(idx, _)) -> idx != index) reglist | ||
18 | |||
19 | let regs_string reglist = List.map (reg_string) reglist |> String.concat "," | ||
20 | |||