vault backup: 2023-10-16 15:07:24
This commit is contained in:
@ -246,11 +246,10 @@ val shard = 'a list -> 'a list -> 'a list -> 'a list = <fun>
|
||||
|
||||
## Exercise 5.1
|
||||
```Ocaml
|
||||
let assos k l =
|
||||
if (k < 0) then
|
||||
invalid_arg "k not natural"
|
||||
else
|
||||
match l with
|
||||
| -> failwith "not found"
|
||||
| (k,y)::t -> y
|
||||
| _ -> assos k t
|
||||
let assos k = function
|
||||
[] -> failwith "not found"
|
||||
| (k2, v2)::t when k2 = k -> v2
|
||||
| (k2, v2):: t when k < k2 -> faiwith "not found"
|
||||
| e::t -> assoc k t
|
||||
val assos = 'a -> ('a + 'b) list -> 'b = <fun>
|
||||
```
|
||||
|
Reference in New Issue
Block a user