vault backup: 2023-10-20 14:21:34

This commit is contained in:
2023-10-20 14:21:34 +02:00
parent 3244da3342
commit 7fbf9619f2
2 changed files with 18 additions and 7 deletions

View File

@ -252,4 +252,16 @@ let assos k = function
| (k2, v2):: t when k < k2 -> faiwith "not found"
| e::t -> assoc k t
val assos = 'a -> ('a + 'b) list -> 'b = <fun>
(*Correction*)
let assoc k l =
if k < 0 then
invalid_arg "k not a natural"
else
let rec findkey k = function
[] -> failwith "not found"
| (ke, ve)::t when k = ke -> ve
| (ke, ve)::t when k < ke -> failwith "not found"
| (ke, ve)::t -> findkey k t
in findkey l
```