vault backup: 2023-10-30 10:14:11

This commit is contained in:
Louis Gallet 2023-10-30 10:14:11 +01:00
parent 3f39d3057c
commit 0a0932f378
Signed by: lgallet
SSH Key Fingerprint: SHA256:qnW7pk4EoMRR0UftZLZQKSMUImbEFsiruLC7jbCHJAY
2 changed files with 22 additions and 16 deletions

View File

@ -78,7 +78,8 @@
} }
], ],
"direction": "horizontal", "direction": "horizontal",
"width": 300 "width": 300,
"collapsed": true
}, },
"right": { "right": {
"id": "b83c16dd7908c658", "id": "b83c16dd7908c658",

23
Exam.md
View File

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