vault backup: 2023-10-30 10:26:22

This commit is contained in:
Louis Gallet 2023-10-30 10:26:22 +01:00
parent 615d8a726a
commit dd1befc4ef
Signed by: lgallet
SSH Key Fingerprint: SHA256:qnW7pk4EoMRR0UftZLZQKSMUImbEFsiruLC7jbCHJAY

20
Exam.md
View File

@ -1,20 +1,12 @@
## Multiple insertion ## Multiple insertion
``` ```
# let insert_mult n x lst = # let rec remove_x x = function
if n <= 0 then
invalid_arg "insert_mult: n must be > 0"
else
let rec aux count = function
| [] -> [] | [] -> []
| e::t -> | e::t ->
if (count = n) then if (e = x) then
e :: x :: aux 1 t remove_x x t
else else e::remove_x x t
e :: aux (count + 1) t
in val remove_x: 'a -> 'a list -> 'a list
match lst with
| [] -> []
| z::f -> z :: aux 0 f
val insert_mult: int -> 'a -> 'a list -> 'a list = <fun>
``` ```