vault backup: 2023-10-20 14:21:34
This commit is contained in:
@ -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
|
||||
```
|
||||
|
Reference in New Issue
Block a user