From b79c8ba9a0bba28a47241fa2bad27682f6436002 Mon Sep 17 00:00:00 2001 From: Louis Date: Fri, 13 Oct 2023 14:58:36 +0200 Subject: [PATCH] vault backup: 2023-10-13 14:58:36 --- .obsidian/workspace.json | 9 ++++----- Algo/Courses/Chapter 6 - Lists (Exercises).md | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.obsidian/workspace.json b/.obsidian/workspace.json index 60f81bb..68a7e58 100644 --- a/.obsidian/workspace.json +++ b/.obsidian/workspace.json @@ -31,8 +31,7 @@ } } } - ], - "currentTab": 1 + ] } ], "direction": "vertical" @@ -169,10 +168,11 @@ "command-palette:Open command palette": false } }, - "active": "c473a791e2b34194", + "active": "eaf65669cfff2a2c", "lastOpenFiles": [ - "Prog/Loops.md", + "Algo/Séminaire/Chapter 1 - CAML basics.md", "Algo/Courses/Chapter 6 - Lists (Exercises).md", + "Prog/Loops.md", "Algo/Courses/Chapter 6 - Lists.md", "Algo/Séminaire/Chapter 5 - Recursivity.md", "Algo/Séminaire/Chapter 4 - A bit of imperative.md", @@ -201,7 +201,6 @@ "COM-ADMR", "Methodologie", "Algo/Séminaire/Introduction.md", - "Algo/Séminaire/Chapter 1 - CAML basics.md", "Algo/Séminaire/assets/exception-meme.png", "Algo/Séminaire/assets/filter-meme.png", "Algo/Séminaire/assets/if-meme.png", diff --git a/Algo/Courses/Chapter 6 - Lists (Exercises).md b/Algo/Courses/Chapter 6 - Lists (Exercises).md index 2a26a5e..7bb1ad0 100644 --- a/Algo/Courses/Chapter 6 - Lists (Exercises).md +++ b/Algo/Courses/Chapter 6 - Lists (Exercises).md @@ -183,4 +183,18 @@ val delete: int -> 'a list -> list = 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;; \ No newline at end of file