vault backup: 2023-10-13 14:58:36
This commit is contained in:
@ -183,4 +183,18 @@ val delete: int -> 'a list -> list = <fun>
|
||||
else if i > length list then
|
||||
failwith "Out of bound"
|
||||
else
|
||||
|
||||
(* Correction *)
|
||||
let insert_nth w i list =
|
||||
if i <= 0 then
|
||||
invalid_arg "negative rank"
|
||||
else
|
||||
let rec insrec i = function
|
||||
[] -> if i > 1 then
|
||||
failwith "out of bound"
|
||||
else
|
||||
x::t
|
||||
| e::E when i = 1 -> x::e::t
|
||||
| e::t -> e::insrec (i - 1) t
|
||||
in insrec i list;;
|
||||
|
Reference in New Issue
Block a user