vault backup: 2023-10-16 15:07:24

This commit is contained in:
2023-10-16 15:07:24 +02:00
parent f625d132c9
commit a0ba6c4c75
2 changed files with 8 additions and 10 deletions

View File

@ -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>
```