From fd68313ddd6e79c68080d0fce1d0334e2c9579f5 Mon Sep 17 00:00:00 2001 From: Louis Date: Fri, 13 Oct 2023 15:12:28 +0200 Subject: [PATCH] vault backup: 2023-10-13 15:12:28 --- Algo/Courses/Chapter 6 - Lists (Exercises).md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Algo/Courses/Chapter 6 - Lists (Exercises).md b/Algo/Courses/Chapter 6 - Lists (Exercises).md index 8fd3335..9f31447 100644 --- a/Algo/Courses/Chapter 6 - Lists (Exercises).md +++ b/Algo/Courses/Chapter 6 - Lists (Exercises).md @@ -190,12 +190,9 @@ let insert_nth w i list = 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 + (1,l) -> x::l + | (_, []) -> failwith "out of bound" + | (i, e::t) -> e::insrec(i-1, t) in insrec i list;; val insert_nth: 'a -> int -> 'a list -> 'a list = \ No newline at end of file