vault backup: 2023-10-30 10:17:51

This commit is contained in:
Louis Gallet 2023-10-30 10:17:52 +01:00
parent 0a0932f378
commit 615d8a726a
Signed by: lgallet
SSH Key Fingerprint: SHA256:qnW7pk4EoMRR0UftZLZQKSMUImbEFsiruLC7jbCHJAY

29
Exam.md
View File

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