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",
"width": 300
"width": 300,
"collapsed": true
},
"right": {
"id": "b83c16dd7908c658",

35
Exam.md
View File

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